結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
![]() |
提出日時 | 2016-10-29 00:33:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,471 bytes |
コンパイル時間 | 1,263 ms |
コンパイル使用メモリ | 124,864 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 22:06:53 |
合計ジャッジ時間 | 4,344 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 98 |
ソースコード
#include<iostream> #include<vector> #include<string> #include<array> #include<algorithm> #include<list> #include<cmath> #include<iomanip> #include<queue> #include<functional> #include<climits> #include<iterator> #include<unordered_set> #include<unordered_map> #include<map> #include<stack> #include<set> #include<typeinfo> #include<numeric> #include<complex> #include<memory> #include<fstream> #include<chrono> #include<random> using namespace std; const double pi=4*atan(1.0); constexpr long long mod=static_cast<long long>(1e9+7); using cWeightEdges=vector<vector<pair<int,int>>>; using cEdges=vector<vector<int>>; int main(){ long long x,y; long long z; cin>>x>>y>>z; bool is_find=false; long long n=1; string ans; if(z==0){ is_find=true; ans="ccW"; } else{ if(x==0 && y==0){ } else if(x==0 && y!=0){ if(z%y==0 && 2*(z/y)-1<=10000){ is_find=true; string s1(z/y,'w'); string s2(z/y-1,'C'); ans=s1+s2; } } else if(x!=0 && y==0){ if(z%x==0 && 2*(z/x)-1<=10000){ is_find=true; string s1(z/x,'c'); string s2(z/x-1,'C'); ans=s1+s2; } } else{ while(2*(n-1)+1<=10000){ long long rest=z-n*x; if(rest%y==0){ long long m=rest/y; if(m==0){ if(2*n-1<=10000){ string s1(n,'c'); string s2(n-1,'C'); ans=s1+s2; } } else{ if(2*n-1+2*abs(m)-1+1<=10000){ is_find=true; string s1(abs(m),'w'); string s2(abs(m)-1,'C'); string s3(n,'c'); string s4(n-1,'C'); if(m>0){ ans+=s1+s2+s3+s4; ans+="C"; } else{ ans+=s1+s2+s3+s4; ans+="W"; } break; } } } ++n; } n=1; if(!is_find){ while(2*(n-1)+1<=10000){ long long rest=z-n*y; if(rest%x==0){ long long m=rest/x; if(m==0){ if(2*n-1<=10000){ string s1(n,'w'); string s2(n-1,'C'); ans=s1+s2; } } else{ if(2*n-1+2*abs(m)-1+1<=10000){ is_find=true; string s1(abs(m),'c'); string s2(abs(m)-1,'C'); string s3(n,'w'); string s4(n-1,'C'); if(m>0){ ans+=s1+s2+s3+s4; ans+="C"; } else{ ans+=s1+s2+s3+s4; ans+="W"; } break; } } } ++n; } } } } if(is_find)cout<<ans<<endl; else cout<<"mourennaihasimasenn"<<endl; //system("pause"); return 0; }