AtCoder Beginner Contest 055
A
1 2 3 4 5 6 7 8 9 10 11 12
| #include<bits/stdc++.h> using namespace std; int main() { int n,x,y; cin>>n; x=n*800; y=(n/15)*200; cout<<x-y<<endl; return 0; }
|
B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #include<bits/stdc++.h> using namespace std; long long s=1; int main(){ int n; cin>>n; for(int i=1;i<=n;i++) { s*=i; s%=1000000007; } cout<<s; return 0; }
|
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #include<bits/stdc++.h> using namespace std; long long n,m; int main() { cin>>n>>m; if(n*2==m) cout<<n<<endl; else if(n*2<m) cout<<n+(m-n*2)/4<<endl; else cout<<m/2<<endl; return 0; }
|
D
由于知道前面两个字母代表的动物就可以推导出来结果,因此只需要正常模拟即可。
这里的递推真是学到了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include<bits/stdc++.h> using namespace std; using ll=long long; const int N=1e6+100; int n; int a[N]; int t[N]; int solve(int x,int y) { t[1]=x; t[2]=y; for(int i=3;i<=n;i++) { t[i]=(a[i-1]+t[i-1]+t[i-2])%2; } if((t[n]+t[1]+t[2])%2==a[1]&&(t[n-1]+t[n]+t[1])%2==a[n]) { for(int i=1;i<=n;i++) { if(!t[i]) { cout<<"S"; } else { cout<<"W"; } } cout<<'\n'; return 1; } else { return 0; } } int main() { cin>>n; string s; cin>>s; for(int i=1;i<=n;i++) { a[i]=(s[i-1]=='x'); } if(solve(0,0)) {} else if(solve(1,0)) {} else if(solve(1,1)) {} else if(solve(0,1)) {} else { cout<<-1<<'\n'; } return 0; }
|
PS:一道有趣题+三道签到题。