結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-10-29 00:26:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,195 bytes |
コンパイル時間 | 1,027 ms |
コンパイル使用メモリ | 89,212 KB |
実行使用メモリ | 813,856 KB |
最終ジャッジ日時 | 2024-11-24 22:33:01 |
合計ジャッジ時間 | 8,701 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 96 WA * 1 MLE * 1 |
ソースコード
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <sstream> #include <algorithm> #include <cstdlib> #include <map> #include <queue> #include <utility> #include <vector> #include <set> #include <memory.h> #include <iomanip> #include <bitset> #include <list> #include <stack> using namespace std; #define mod 1000000007 string solve(int x, char cx, int y, char cy, int z) { if(y == 0){ if(x == 0) return ""; if(z % x == 0){ string first(z / x, cx); string second(z / x - 1, 'C'); if((first + second).length() <= 10000) return first + second; } return ""; } for(int xnum = 2; xnum < 10000; xnum++){ if(abs(z - x * xnum) % y != 0) continue; int ynum = (z - x * xnum) / y; if(ynum == 0){ string first(xnum, cx); string second(xnum - 1, 'C'); if((first + second).length() > 10000) continue; return (first + second); } int tmpy = abs(ynum); string first(tmpy, cy); string second(xnum, cx); string third(xnum - 1, 'C'); string fourth; if(ynum < 0){ string tmp(-ynum, 'W'); fourth = tmp; } else { string tmp(ynum, 'C'); fourth = tmp; } string ans = first + second + third + fourth; if(ans.length() > 10000) continue; return ans; } return ""; } int main() { int x, y, z; cin >> x >> y >> z; if(x + y == z){ cout << "cwC" << endl; return 0; } else if(x - y == z){ cout << "wcW" << endl; return 0; } else if(y - x == z){ cout << "cwW" << endl; return 0; } else if(x == z){ cout << "c" << endl; return 0; } else if(y == z){ cout << "w" << endl; return 0; } else if(z == 0){ cout << "ccW" << endl; return 0; } string ans = "mourennaihasimasenn"; string tmp1 = solve(x, 'c', y, 'w', z), tmp2 = solve(y, 'w', x, 'c', z); if(tmp1 != "") ans = tmp1; else if(tmp2 != "") ans = tmp2; cout << ans << endl; return 0; }