A - Creating Words
题意:略
代码:
#include#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)//不能使用scanf了 #define int long long #define loop(n) for(int i=0;i =0;i--) #define print(c) cout<<"this "#c" is "< >a>>b; char c=a[0]; a[0]=b[0]; b[0]=c; cout<> n; while (n--)solve(); }
B - Maximum Multiple Sum
题意:略
代码:
#include#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define int long long #define loop(n) for(int i=0;i =0;i--) #define print(c) cout<<"this "#c" is "< >n; auto check=[&](int t){ int i=2; for(;i<=sqrt(t);i++) if(t%i==0)break; if(i>=sqrt(t))return 1; else return 0; }; if(n<4)cout< > n; while (n--)solve(); }
C - Good Prefixes
题意:给数组a[n],然后定义数组的2*max=sum,则认为这个数组是好数组
我们求sum和max,然后比较即可,可以用递推优化
代码:
#include#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define int long long #define loop(n) for(int i=0;i =0;i--) #define print(c) cout<<"this "#c" is "< >n; int a[n]; loop(n)cin>>a[i]; int S[n],Max[n]; loop(n){ if(i==0)S[i]=a[i],Max[i]=a[i]; else S[i]=S[i-1]+a[i],Max[i]=max(Max[i-1],a[i]); } int count=0; loop(n) if(S[i]==2*Max[i])count++; cout< > n; while (n--)solve(); }
D - Manhattan Circle
题意:找圆的圆心
代码:
#include#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define int long long #define loop(n) for(int i=0;i =0;i--) #define print(c) cout<<"this "#c" is "< >n>>m; char a[n][m]; int line=n-1,num=0,first=0; for(int i=0;i >a[i][j]; for(int i=0,count=0,k=0;i > n; while (n--)solve(); }
还没有评论,来说两句吧...