結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-29 02:10:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,000 bytes |
| コンパイル時間 | 1,958 ms |
| コンパイル使用メモリ | 169,416 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-24 23:01:16 |
| 合計ジャッジ時間 | 6,800 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 94 RE * 4 |
ソースコード
#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 (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;
}
}