#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\n" ;
}
else if(x%4==2){
cout << "1 B\n";
}
return 0;
}
分情况,三个花色相同,两个花色相同,然后里面再分。。。。。。
#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\n";
return 0;
}
if(a[0]+1==a[1]&&a[1]+1==a[2]){
cout<<"0\n";
return 0;
}
else if(a[0]+1==a[1]||a[1]+1==a[2]){
cout<<"1\n";
return 0;
}
else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[0]){
cout<<"1\n";
return 0;
}
}
if(str[0][1]==str[1][1]&&abs(a[0]-a[1])<=2){
cout<<"1\n";
return 0;
}
if(str[0][1]==str[2][1]&&abs(a[0]-a[2])<=2){
cout<<"1\n";
return 0;
}
if(str[1][1]==str[2][1]&&abs(a[1]-a[2])<=2){
cout<<"1\n";
return 0;
}
cout<<"2\n";
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\n",cnt);
return 0;
}
Codeforces Round #573 (Div. 2) A B C
原文:https://www.cnblogs.com/YJing814/p/11180019.html