Codeforces Round #573 (Div. 2) A B C D

ATokitsukaze and Enhancement

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+100;

int x;
int main(){
	cin >> x;
	int cnt = 0;
	if( x%4 <= 1 || x%4==3){
		if (x%4==0) cnt=1;
		if(x%4 ==3) cnt=2;
		cout << cnt << " A
" ;
	}
	else if(x%4==2){
		cout << "1 B
";
	}
	return 0;
}

  BTokitsukaze and Mahjong

分情况,三个花色相同,两个花色相同,然后里面再分。。。。。。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char str[3][2];
int a[3];
int main(){
	cin>>str[0]>>str[1]>>str[2];
	for(int i=0;i<3;i++){
		a[i]=str[i][0]-'0';
	}
	
	if(str[0][1]==str[1][1]&&str[0][1]==str[2][1]){
		sort(a,a+3);
		if(a[0]==a[1]&&a[1]==a[2]){
			cout<<"0
";
			return 0;
		}
		if(a[0]+1==a[1]&&a[1]+1==a[2]){
			cout<<"0
";
			return 0;
		}
		else if(a[0]+1==a[1]||a[1]+1==a[2]){
			cout<<"1
";
			return 0;
		}
		else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[0]){
			cout<<"1
";
			return 0;
		}
	}
	if(str[0][1]==str[1][1]&&abs(a[0]-a[1])<=2){ 
		cout<<"1
";
		return 0;
	}
	if(str[0][1]==str[2][1]&&abs(a[0]-a[2])<=2){ 
		cout<<"1
";
		return 0;
	}
	if(str[1][1]==str[2][1]&&abs(a[1]-a[2])<=2){ 
		cout<<"1
";
		return 0;
	}
	cout<<"2
";
	return 0;
}

  CTokitsukaze and Discard Items

只看数组p,然后走完一页删一页,直接定位到下一个p[i]的页面

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e5+100;
ll n,m,k;
ll p[M];
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=0;i<m;i++){
		scanf("%lld",&p[i]);
	}
	int cnt=0;
	int c=0;
	ll y=1;
	for(int i=0;i<m;){
		int j=i;
		for(;j<m;j++){
			if(p[j]>k*y+c) break;
		}
		c=j;
		if(j!=i)cnt++;
		if(p[j]>k*y+c) y=(p[j]-c+k-1)/k;
		i=j;
	}
	printf("%d
",cnt);
	return 0;
}

  

  D:D - Tokitsukaze, CSL and Stone Game

给n堆石子,每一堆有a[i] 个 石头,现在二人玩游戏,每一人每一次选择一个非空的石头堆,从中拿出一个石头。如果当一个人操作之后,这n堆石头中有两堆中的石头数量是相同的,那么这个人就输掉。假设二人决定聪明,请判断是先手赢还是后手赢。 

通过思考我们可以知道初始情况是以下情况先手必输

  • 空堆的数量 >=2
  • 有三个堆中石头数量相等 或者 有至少两 对 堆中石头数量相等。
  • 有这种情况 x x x-1

如果先手不必输,那么二人的最优操作之后,石子堆一定会到达这个状态 (无顺序) 0,1,2,3,,,n-1

我们只需要求a[i] 的sum和然后减去 等差数列的前列项和后判断奇偶即可。

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
typedef long long ll;
int n;
int a[N];
int main(){
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=(ll) a[i] - i ;
	}
	sort(a,a+n);
	if(a[0]==a[1] && a[0]==0){
		cout<<"cslnb
";
		return 0;
	}
	int cnt=0;
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			cnt++;
		}
		else if(i<n-2 && a[i]==a[i+1]-1 && a[i+1]==a[i+2]){
			cout<<"cslnb
";
			return 0;
		}
	}
	if(cnt>=2) {
		cout<<"cslnb
";
		return 0;
	}
	if(sum%2)
		cout<<"sjfnb
";
	else
		cout<<"cslnb
";
	return 0;
}

  

原文地址:https://www.cnblogs.com/YJing814/p/11180019.html