Codeforces Round #258 (Div. 2)
2014-07-25 15:52
169 查看
好长时间没写过博客了。
A、因为每次都要取走一横一竖,所以只要取其中较小值判断奇偶性就行来 。
B、符合条件的的序列只有三种,分别是单调递减、单调递增和递增但是中间有一部分逆序。
前两种情况很好判断,第三种稍微麻烦一点儿。给序列添加一个极小的队首和一个极大的队尾,然后再处理会方便很多。
C、这次C题好像比较简单的样子。一共有四种情况,枚举每一种情况得出一个方程组,人工对方程组求解,分别对每一种情况进行判断。其中只要有一种符合条件就输出"yes",否则输出"no"。
判断的条件是三个值都是非负数且三个值都小于等于n/3。
D、比赛的时候没有做出来。那会儿有点儿消极比赛的意思。因为题目保证了字符串中只包含字母‘a'和'b',相同的字符可以合并。可以得到只要字符串首位相同就一定是good string。
计算方法是分别记录奇数位上字符'a'出现的次数,’b'出现的次数,偶数位上字符'a'出现的次数,'b'出现的次数。然后结果是:
ansj=ja*(ja-1)/2+jb*(jb-1)/2+oa*(oa-1)/2+ob*(ob-1)/2+len;
anso=ja*oa+jb*ob;
A、
B、
C、
D题写的时候看过别人的代码,链接:点击打开链接
A、因为每次都要取走一横一竖,所以只要取其中较小值判断奇偶性就行来 。
B、符合条件的的序列只有三种,分别是单调递减、单调递增和递增但是中间有一部分逆序。
前两种情况很好判断,第三种稍微麻烦一点儿。给序列添加一个极小的队首和一个极大的队尾,然后再处理会方便很多。
C、这次C题好像比较简单的样子。一共有四种情况,枚举每一种情况得出一个方程组,人工对方程组求解,分别对每一种情况进行判断。其中只要有一种符合条件就输出"yes",否则输出"no"。
判断的条件是三个值都是非负数且三个值都小于等于n/3。
D、比赛的时候没有做出来。那会儿有点儿消极比赛的意思。因为题目保证了字符串中只包含字母‘a'和'b',相同的字符可以合并。可以得到只要字符串首位相同就一定是good string。
计算方法是分别记录奇数位上字符'a'出现的次数,’b'出现的次数,偶数位上字符'a'出现的次数,'b'出现的次数。然后结果是:
ansj=ja*(ja-1)/2+jb*(jb-1)/2+oa*(oa-1)/2+ob*(ob-1)/2+len;
anso=ja*oa+jb*ob;
A、
#include<stdio.h> int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) { int temp; if(m<n) temp=m; else temp=n; if(temp%2) printf("Akshat\n"); else printf("Malvika\n"); } return 0; }
B、
#include<stdio.h> #include<string.h> #define N 100005 int a ; int main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=1; i<=n; i++) scanf("%d",&a[i]); int flag=0; a[0]=-1; for(int i=1; i<=n; i++) { if(a[i]<a[i-1]) { flag=1; break; } } if(!flag) { printf("yes\n"); printf("1 1\n"); continue; } flag=0; a[0]=1000000007; for(int i=1; i<=n; i++) { if(a[i]>a[i-1]) { flag=1; break; } } if(!flag) { printf("yes\n"); printf("1 %d\n",n); continue; } a[0]=-1; a[n+1]=1000000007; int a1,a2,a3,a4; int x,y; flag=0; for(int i=1; i<=n; i++) { if(a[i]>a[i-1]) continue; if(a[i]<a[i-1]) { a1=a[i-2]; a2=a[i-1]; x=i-1; flag++; } while(i<=n&&a[i]<a[i-1]) i++; a3=a[i-1]; a4=a[i]; y=i-1; } if(flag==1&&a3>a1&&a4>a2) { printf("yes\n"); printf("%d %d\n",x,y); } else printf("no\n"); } return 0; }
C、
#include<stdio.h> #include<string.h> typedef __int64 LL; LL Max(LL a,LL b) { if(a>b) return a; else return b; } int main() { int T; scanf("%d",&T); while(T--) { LL n,k,d1,d2; scanf("%I64d%I64d%I64d%I64d",&n,&k,&d1,&d2); if(n%3!=0) { printf("no\n"); continue; } LL temp=n/3; LL a,b,c,max; max=-1; if((k-2*d1-d2)%3==0) { a=(k-2*d1-d2)/3; b=a+d1; c=b+d2; max=Max(Max(a,b),c); if(max<=temp&&a>=0&&b>=0&&c>=0) { printf("yes\n"); continue; } } max=-1; if((k-d1-d2)%3==0) { a=(k-d1-d2)/3; b=a+d1; c=a+d2; max=Max(Max(a,b),c); if(max<=temp&&a>=0&&b>=0&&c>=0) { printf("yes\n"); continue; } } max=-1; if((k+d1+d2)%3==0) { a=(k+d1+d2)/3; b=a-d1; c=a-d2; max=Max(Max(a,b),c); if(max<=temp&&a>=0&&b>=0&&c>=0) { printf("yes\n"); continue; } } max=-1; if((k-2*d2-d1)%3==0) { a=(k-2*d2-d1)/3; b=a+d1; c=b+d2; max=Max(Max(a,b),c); if(max<=temp&&a>=0&&b>=0&&c>=0) { printf("yes\n"); continue; } } printf("no\n"); } return 0; }
D题写的时候看过别人的代码,链接:点击打开链接
相关文章推荐
- Codeforces Round #258 (Div. 2)题解(ALL)
- Codeforces Round #258 (Div. 2) A. Game With Sticks(数学题)
- Codeforces Round #258 (Div. 2)Devu and Flowers 容斥原理
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game
- Codeforces Round #258 (Div. 2)-(A,B,C,D,E)
- Codeforces Round #258 (Div. 2)
- Codeforces Round #258 (Div. 2)[ABCD]
- Codeforces Round #258 (Div. 2) B. Sort the Array (模拟)
- Codeforces Round #258 (Div. 2)E(组合数+容斥原理)
- Codeforces Round #258 (Div. 2) A. Game With Sticks
- Codeforces Round #346 (Div. 2) A. Round House
- Codeforces Round #102 (Div. 2) ——A. Help Vasilisa the Wise 2
- Codeforces Round #196 (Div. 2)
- Codeforces Round #164(Div. 2) B. Buttons【找规律】
- Codeforces Round #433 (Div. 2 D. Jury Meeting 二分
- Codeforces Round #173 (Div. 2) / 282A Bit++(模拟)
- 【Educational Codeforces Round 53 (Rated for Div. 2)】
- 【Codeforces Round #170 Div. 1】 227A Learning Languages
- Codeforces Round #420 (Div. 2) 821
- Codeforces Round #420 (Div. 2) 题解