結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
|
提出日時 | 2016-10-29 02:11:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,065 bytes |
コンパイル時間 | 1,503 ms |
コンパイル使用メモリ | 169,040 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 23:01:22 |
合計ジャッジ時間 | 5,767 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 95 RE * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, z; cin >> x >> y >> z; tuple<int, int, int> mn(INT_MAX, INT_MAX, INT_MAX); for (int i = -5000; i <= 5000; i++) { int j = y == 0 ? 0 : (z - i * x) / y; if (i * x + j * y == z) mn = min(mn, make_tuple(abs(i) * 2 + abs(j) * 2 - 1, i, j)); } int c, a, b; tie(c, a, b) = mn; if (c > 10000) { cout << "mourennaihasimasenn" << endl; return 0; } if (x == 0 && y == 0 && z == 0) { cout << "c" << endl; } else if (b == 0) { cout << string(a, 'c') + string(a - 1, 'C') << endl; } else if (a == 0) { cout << string(b, 'w') + string(b - 1, 'C') << endl; } else if (a > 0 && b > 0) { cout << string(a, 'c') + string(a - 1, 'C'); cout << string(b, 'w') + string(b - 1, 'C'); cout << "C" << endl; } else if (a < 0) { cout << string(-a, 'c') + string(-a - 1, 'C'); cout << string(b, 'w') + string(b - 1, 'C'); cout << "W" << endl; } else { cout << string(-b, 'w') + string(-b - 1, 'C'); cout << string(a, 'c') + string(a - 1, 'C'); cout << "W" << endl; } }