第一次AK的ABC
虽然题非常简单
但是值得纪念一下
T1
一道很水的题
不存在做法
纯粹乱跑
但是我把Yes打成YES了,哭唧唧
#include#include #include using namespace std;int main(){ int a,b; scanf("%d %d",&a,&b); if((1*a*b)%2==1||(2*a*b)%2==1||(3*a*b)%2==1) printf("Yes\n"); else printf("No\n"); return 0;}
T2
就是普通的判重和模拟
stl真好用
#include#include #include #include #include #include using namespace std;int n;set s;string a;char lat;int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ cin>>a; if(s.count(a)){ printf("No\n"); return 0; } if(i>1&&a[0]!=lat){ printf("No\n"); return 0; } lat=a[a.length()-1]; s.insert(a); } printf("Yes\n"); return 0;}
T3
有趣的GCD应用
秒掉
#include#include #include #define int long longusing namespace std;int n,x,pos[110000];int gcd(int a,int b){ return (b==0)?a:gcd(b,a%b);}signed main(){ scanf("%lld %lld",&n,&x); for(int i=1;i<=n;i++) scanf("%lld",&pos[i]); for(int i=1;i<=n;i++) pos[i]-=x; ++n; pos[n]=0; sort(pos+1,pos+n+1); int ans=pos[2]-pos[1]; for(int i=2;i<=n-1;i++){ ans=gcd(ans,pos[i+1]-pos[i]); } printf("%lld",ans); return 0;}
T4
乍一看不好做其实很水的构造
#include#include #include #define int long longusing namespace std;int mat[510][510],mat2[510][510],ans=0;int h,w;signed main(){ scanf("%lld %lld",&h,&w); for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) scanf("%lld",&mat[i][j]),mat2[i][j]=mat[i][j]; for(int i=1;i<=h;i++) for(int j=1;j<=w-1;j++){ if(mat2[i][j]%2==0) continue; else{ ans++; mat2[i][j+1]++; mat2[i][j]--; } //ans+=mat2[i][j],mat2[i][j+1]+=mat2[i][j],mat2[i][j]=0; } for(int i=1;i<=h-1;i++){ //ans+=mat2[i][w],mat2[i+1][w]+=mat2[i][w],mat2[i][w]=0; if(mat2[i][w]%2==0) continue; else{ ans++; mat2[i+1][w]++; mat2[i][w]--; } } printf("%lld\n",ans); for(int j=1;j<=h;j++) for(int i=1;i<=w-1;i++){ if(mat[j][i]%2==0) continue; else{ printf("%lld %lld %lld %lld\n",j,i,j,i+1); mat[j][i+1]++; mat[j][i]--; }// for(int k=1;k<=mat[j][i];k++){// printf("%d %d %d %d\n",j,i,j,i+1);// mat[j][i+1]+=1;// }// mat[j][i]=0; } for(int i=1;i<=h-1;i++){ if(mat[i][w]%2==0) continue; else{ mat[i+1][w]++; mat[i][w]--; printf("%lld %lld %lld %lld\n",i,w,i+1,w); } }// for(int k=1;k<=mat[i][w];k++)// printf("%d %d %d %d\n",i,w,i+1,w),mat[i+1][w]++; return 0;}