博弈论 ————————

A.Matches Game 

就是nim模板 异或和

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
    int n;
    while(cin>>n){
        int ans=0,x;
        for(int i=1;i<=n;i++){
            cin>>x;
            ans^=x;
        }
        if(ans) cout<<"Yes"<<endl;
        else    cout<<"No"<<endl;
    }
    return 0;
}

B.以为后手总是可以走先手的走的路 所以我们找出最大的距离的最大次数 

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
void solve(){
	int d,k;cin>>d>>k;int maxx=0;
	for(int i=0;i<=d;i+=k){
		int x=i,y=sqrt(d*d-x*x);
		maxx=max(maxx,x/k+y/k);
	}
	if(maxx&1)cout<<"Ashish"<<'\n';
	else cout<<"Utkarsh"<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
} 

C. 结果是有两个子叶(x和其他) 所以必胜态就是偶数 再加一些特判

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int a[100005];
void solve(){
	int n,x;cin>>n>>x;memset(a,0,sizeof a);
	for(int i=1;i<=n-1;i++){
		int u,v;cin>>u>>v;
		a[u]++;a[v]++;
	}
	if(n==1||a[x]==1||n%2==0){
		 cout<<"Ayush"<<endl;
    }
    else
        cout<<"Ashish"<<endl;
    }

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	//int t=1;
	while(t--){
		solve();
	}
} 

D. 最多可以操作(n-11)/2次 所以我们只需要统计比较一下即可

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int a[100005];
void solve(){
	int n;cin>>n;
	string s;cin>>s;int cnt1=0,cnt2=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='8')cnt1++;
		else cnt2++;
		if(cnt1>(n-11)/2)break; 
	}
	if(cnt2>(n-11)/2)cout<<"NO"<<'\n';
	else cout<<"YES"<<'\n'; 
}

signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	//int t;cin>>t;
	int t=1;
	while(t--){
		solve();
	}
} 

G. nim博弈 

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=1001;
int n,a[maxn];
int main()
{
    while(scanf("%d",&n)&&n)
    {
	int t=0;
	for(int i=0;i<n;i++)
	{
	    scanf("%d",&a[i]);
	    t^=a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	    if((t^a[i])<a[i])
		ans++;
	printf("%d\n",ans);
    }
    return 0;
}

I. 如果有两个质因子就可以

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
void solve(){
	int n;vector<int> v;
	while(cin>>n){
		v.clear();
		for(int i=2;i*i<=n;i++){
			while(n%i==0){
				v.pb(i);
				n/=i;
			}
		}
		if(n>1)v.pb(n);
		if(v.size()<2)cout<<1<<'\n'<<0<<'\n';
		else if(v.size()==2)cout<<2<<'\n';
		else cout<<1<<'\n'<<v[0]*v[1]<<'\n'; 
	}
}
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t=1;
	while(t--){
		solve();
	}
} 

J. 1是失败 状态转移就是2或者一个奇数(必胜态)那么就是两种可能 第一种是一个2*奇数必败 2^n就必胜态 无法整除一个奇数只能-1变成必败态 必胜态就是2^n*某个素数 2*素数的必胜态就是2*素数的^n

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
bool go(int x){
	for(int i=2;i<=x/i;i++){
		if(x%i==0)return 0;
	}
	return 1;
}
void solve(){
	int n;cin>>n;bool ok;
	if(n==1){
		cout<<"FastestFinger"<<'\n';return ;
	}
	if(n&1||n==2){
		cout<<"Ashishgup"<<'\n';return ;
	}
	if(n%4==0){
		while((n&1)==0)n>>=1;
		if(n==1)ok=0;
		else ok=1;
	}
	else {
		n>>=1;
		if(go(n))ok=0;
		else ok=1;
	}
	if(ok)cout<<"Ashishgup"<<'\n';
	else cout<<"FastestFinger"<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	int t;cin>>t;
	while(t--){
		solve();
	}
} 

K. 当k>=2 总是可以分成两部分 

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
void solve(){
	int n,k;cin>>n>>k;
	if(n==0)cout<<"Austin";
	else if(k==1){
		if(n&1)cout<<"Adrien";
		else cout<<"Austin";
	} 
	else if(k>1)cout<<"Adrien"; 
}
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	//int t;cin>>t;
	int t=1;
	while(t--){
		solve();
	}
} 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值