結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
|
提出日時 | 2016-10-29 02:13:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,056 bytes |
コンパイル時間 | 1,659 ms |
コンパイル使用メモリ | 167,396 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 22:11:16 |
合計ジャッジ時間 | 5,251 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 98 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, z; cin >> x >> y >> z; if (z == 0) { cout << "ccW" << endl; return 0; } 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 (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; } }