結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
|
提出日時 | 2016-10-28 23:10:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,725 bytes |
コンパイル時間 | 1,025 ms |
コンパイル使用メモリ | 107,496 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 18:42:01 |
合計ジャッジ時間 | 4,423 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 95 WA * 1 RE * 2 |
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; const int MAX = 10000; string solve(int x, int y) { if(x < 0){ string s = solve(y, x); for(unsigned i=0; i<s.size(); ++i){ if(s[i] == 'c') s[i] = 'w'; else if(s[i] == 'w') s[i] = 'c'; } return s; } string ans; if(y < 0){ ans = string(-y, 'w') + string(x, 'c') + string(x - 1, 'C') + string(-y, 'W'); } else{ ans = string(x, 'c') + string(y, 'w') + string(x + y - 1, 'C'); } return ans; } int main() { long long x, y, z; cin >> x >> y >> z; if(x == 0 && y == 0){ if(z == 0) cout << "c" << endl; else cout << "mourennaihasimasenn" << endl; return 0; } for(int i=-MAX; i<=MAX; ++i){ long long a = z - x * i; long long j = 0; if(y == 0){ if(a != 0) continue; } else{ if(a % y != 0) continue; j = a / y; if((abs(i) + abs(j)) * 2 - 1 > MAX) continue; } string ans = solve(i, j); cout << ans << endl; return 0; } cout << "mourennaihasimasenn" << endl; return 0; }