結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
|
提出日時 | 2016-10-29 01:32:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,994 bytes |
コンパイル時間 | 1,054 ms |
コンパイル使用メモリ | 106,892 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 22:52:21 |
合計ジャッジ時間 | 4,660 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 96 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 makeCommand(int x, int y) { if(x < 0){ string s = makeCommand(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; } if(y < 0){ return string(-y, 'w') + string(x, 'c') + string(x - 1, 'C') + string(-y, 'W'); } else{ return string(x, 'c') + string(y, 'w') + string(x + y - 1, 'C'); } } string solve(int x, int y, int z) { if(x == 0 && y == 0){ if(z == 0) return "c"; else return "mourennaihasimasenn"; } else if(x == 0){ if(z % y == 0 && z / y * 2 - 1 <= MAX) return string(z / y, 'w') + string(z / y - 1, 'C'); else return "mourennaihasimasenn"; } else if(y == 0){ if(z % x == 0 && z / x * 2 - 1 <= MAX) return string(z / x, 'c') + string(z / x - 1, 'C'); else return "mourennaihasimasenn"; } for(long long i=-MAX; i<=MAX; ++i){ long long a = z - x * i; if(a % y != 0) continue; long long j = a / y; long long len = abs(i) + abs(j); len = len * 2 - 1; if(len > MAX) continue; return makeCommand(i, j); } return "mourennaihasimasenn"; } int main() { long long x, y, z; cin >> x >> y >> z; cout << solve(x, y, z) << endl; return 0; }