Heim  >  Artikel  >  Web-Frontend  >  CF #269 DIV2 A,B,C,D_html/css_WEB-ITnose

CF #269 DIV2 A,B,C,D_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:57:091241Durchsuche

A

http://codeforces.com/contest/471/problem/A

解题思路:给你6个数,问是否有至少4个数都相等,没有的话输出“Alien”,有的话再看剩下的两个数,如果相等就输出"

Elephant",否则输出"
Bear";

<pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rtB</utility></cmath></bitset></vector></deque></stack></queue></list></map></set></algorithm></string></cstring></cstdio></iostream>

http://codeforces.com/contest/471/problem/B

解题思路:给你一个序列,问是否有三种不同的方法使它们按非减序排序,显然只有有2个相等的元素集合数大于等于2时或者有3个相等的元素的集合时才有解,有解的时候集合内排序一下,我写的很繁,导致后面的题目没写,整场就跪了

<pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt2)			{				flag=true;				break;			}			if(m[i]==2)				cnt++;		}		if(flag||cnt>=2)		{			puts("YES");			sort(arr+1,arr+1+n);			if(flag)			{				for(i=1;i2)						break;				}				int a=arr[i].id;				int b=arr[i+1].id;				int c=arr[i+2].id;				//couti+2)					{						printf("%d%c",arr[j].id,j==n?'\n':' ');					}					else if(i==n-2)					{						printf("%d %d %d\n",a,b,c);						j+=2;					}					else					{						printf("%d %d %d ",a,b,c);						j+=2;					}				}				for(j=1;ji+2)					{						printf("%d%c",arr[j].id,j==n?'\n':' ');					}					else if(i==n-2)					{						printf("%d %d %d\n",b,a,c);						j+=2;					}					else					{						printf("%d %d %d ",b,a,c);						j+=2;					}				}				for(j=1;ji+2)					{						printf("%d%c",arr[j].id,j==n?'\n':' ');					}					else if(i==n-2)					{						printf("%d %d %d\n",c,b,a);						j+=2;					}					else					{						printf("%d %d %d ",c,b,a);						j+=2;					}				}			}			else			{				int f1,f2;				for(i=1;if1+1)&&(i<f2>f2+1))						printf("%d%c",arr[i].id,i==n?'\n':' ');					else if(i>=f1&&i=f2&&if1+1)&&(i<f2>f2+1))						printf("%d%c",arr[i].id,i==n?'\n':' ');					else if(i>=f1&&i=f2&&if1+1)&&(i<f2>f2+1))						printf("%d%c",arr[i].id,i==n?'\n':' ');					else if(i>=f1&&i=f2&&iC </f2></f2></f2></utility></cmath></bitset></vector></deque></stack></queue></list></map></set></algorithm></string></cstring></cstdio></iostream>

http://codeforces.com/contest/471/problem/C

解题思路:首先二分出n个棍子最多可以搭几层,然后从1开始枚举,注意到每一层的数目都是一个公差为3的等差数列,判断一下这一层能否满足n的需求即可

<pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt=l)		{			LL m=(l+r)>>1;			if(cal(m)<strong>D</strong></utility></cmath></bitset></vector></deque></stack></queue></list></map></set></algorithm></string></cstring></cstdio></iostream>

<strong>http://codeforces.com/problemset/problem/471/D</strong>

<strong>解题思路:做出两个数列的相邻两项的差分数列,KMP判断短的差分数列在长的差分数列中出现几次即可,特判n=1和w=1的情况</strong>

<strong></strong><pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <vector>#include <bitset>#include <cmath>#include <utility>#define Maxn 100005#define Maxm 1000005#define lowbit(x) x&(-x)#define lson l,m,rt=1)				ca[i-1]=a[i]-a[i-1];		}		for(int i=0;i<n scanf if>=1)				cb[i-1]=b[i]-b[i-1];		}		if(m==1||n==1)		{			printf("%d\n",max(m,n));			continue;		}		printf("%d\n",m>=n?kmp(ca,cb,m-1,n-1):kmp(cb,ca,n-1,m-1));	}	return 0;}</n></utility></cmath></bitset></vector></deque></stack></queue></list></map></set></algorithm></string></cstring></cstdio></iostream>


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn