Created
January 20, 2014 15:51
-
-
Save rptynan/fa0c0687d498cb98f8ab to your computer and use it in GitHub Desktop.
Solutions to AIPO 2012, rushed and silly..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| int m, x; | |
| int main(){ | |
| cin>>m>>x; | |
| cout<<2*x-m<<endl; | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| unsigned long long x; | |
| int t, i; | |
| int main(){ | |
| cin>>t; | |
| for(; t>0; --t){ | |
| x=1; | |
| cin>>i; | |
| for(; i>0; --i) x*=i; | |
| cout<<x<<endl; | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| string in, out; | |
| int n; | |
| int main(){ | |
| cin>>n>>in>>out; | |
| for(int i=0; i<in.size(); ++i){ | |
| if(in[i] != (out[i] ^ (n%2))){ | |
| cout<<"Deletion failed"<<endl; | |
| return 0; | |
| } | |
| } | |
| cout<<"Deletion succeeded"<<endl; | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| #include <cstdlib> | |
| #include <cstdio> | |
| using namespace std; | |
| string num; | |
| char tmp[1000]; | |
| long long N, t; | |
| inline bool pal(string num){ | |
| for(int q=0, p=num.size()-1; q<p; ++q, --p) | |
| if(num[q]!=num[p]) return false; | |
| return true; | |
| } | |
| inline string rev(string num){ | |
| string out; | |
| for(int i=num.size()-1; i>=0; --i){ | |
| out+=num[i]; | |
| } | |
| return out; | |
| } | |
| int main(){ | |
| cin>>N; | |
| for(int n=0; n<N; ++n){ | |
| cin>>num; | |
| t=0; | |
| while(!pal(num)){ | |
| sprintf(tmp,"%lld",atol(num.c_str())+atol(rev(num).c_str())); | |
| num=string(tmp); | |
| ++t; | |
| } | |
| cout<<num<<' '<<t<<endl; | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <algorithm> | |
| using namespace std; | |
| int N, days[100000]; | |
| int main(){ | |
| cin>>N; | |
| for(int i=0; i<N; ++i){ | |
| cin>>days[i]; | |
| } | |
| sort(days,days+N); | |
| int mr=0; | |
| for(int t=1; t<=N; ++t){ | |
| --mr; | |
| mr=max(days[N-t],mr); | |
| } | |
| cout<<N+1+mr<<endl; | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| #define MAXN 1000 | |
| int N1, N2, N, T; | |
| string sn2, t, in; | |
| int main(){ | |
| cin>>N1>>N2; | |
| N=N1+N2; | |
| in.resize(N); | |
| cin>>t; | |
| cin>>sn2; | |
| cin>>T; | |
| string sn1(t.rbegin(),t.rend()); | |
| for(int i=T; i>=0; --i){ | |
| if(sn2.length()==0) break; | |
| sn1.insert(max(sn1.end()-i,sn1.begin()+T-i),sn2[0]); | |
| sn2.erase(0,1); | |
| } | |
| sn1+=sn2; | |
| cout<<sn1<<endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment