Codeforces Round #651 (Div. 2) A-D

497 xilinshancun101 4246 +19 1989 → 2008

过了前四题。

卡E。。E差点做出来,最后正确思路刚想出来,就结束了。。(还是没抓住问题本质,中间还刚了一会F)

A:最大gcd(a,b)肯定是 gcd(x,2*x).  直接n/2即可

#include 
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
 
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int t;
	  cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		cout<

B:

显然,让gcd==2即可。

偶数+偶数等于偶数

奇数+奇数等于偶数,

最后最多只会剩一个奇数+一个偶数  刚好这一对删去。。


#include 
using namespace std;
typedef long long ll;
const double PI= acos(-1.0);
const int M = 1e4+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
 
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int t;
  	cin>>t;
  	while(t--)
  	{
  		int n,x;
  		cin>>n;
  		queueji,ou;
  		for(int i=1;i<=2*n;i++)
  		{
  			cin>>x;
  			if(x&1)ji.push(i);
  			else ou.push(i);
		}
		for(int i=1;i=2)
			{
				int a=ji.front();ji.pop();
				int b=ji.front();ji.pop();
				cout<

C:

1是必输状态

2是必胜状态(减1后达到必输态)。

奇数一定是必胜态(直接除以本身达到1)

如果一个数是偶数:

如果它没有奇数质因子,则先手只能减一,到达必胜态,即先手必败。

如果它有奇数质因子,则先手可以直接把所有质因子消去,达到先手必败的偶数。

以上是全部情况,分情况讨论下即可。

#include 
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int p[M],c[M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int t;
  	cin>>t;
  	while(t--)
  	{
  		int N,n;
  		cin>>n;
  		N=n;
  		if(n==1)
  		{
  			cout<<"FastestFinger"<

D:

显然,结果满足二分性。

x表示  最终最小值不大于x。

那么我们把a数组大于x的都标记0,小于等于x的标记1.

则选出的size为k的b数组只能选取a中标记为1的。

然后分奇偶数组进行选取即可。

注意k等于奇数时,偶数不能选首末。

k等于偶数时,奇数不能选末,偶数不能选首

#include 
using namespace std;
typedef long long ll;
const int M = 2e5+7;
int a[M],b[M];
int n,k;
bool ck(int x)//最大值要小于等于x 
{
	for(int i=1;i<=n;i++)if(a[i]<=x)b[i]=1;else b[i]=0;
	int nm=(k+1)/2;
	int tp=-1,ji=1,ou=1;
	for(int i=1;i<=nm;i++)
	{
		bool f=false;
		int up=n;
		if(k%2==0)up=n-1;
		for(int j=tp+2;j<=up;j++)
			if(b[j]==1)
			{
				tp=j;f=true;break;
			}
		if(!f)
		{
			ji=0;
			break;
		}
	}
	nm=k/2;tp=0;
//	cout<>n>>k;
  	for(int i=1;i<=n;i++)cin>>a[i];
  	int l=1,r=1e9+10,ans=0;
  	while(l<=r)
  	{
  	//	cout<

 

你可能感兴趣的:(CF)