結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
|
提出日時 | 2016-10-28 23:38:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,092 bytes |
コンパイル時間 | 868 ms |
コンパイル使用メモリ | 71,784 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-24 20:22:24 |
合計ジャッジ時間 | 16,887 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 40 WA * 51 RE * 5 TLE * 2 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))typedef long long ll;using namespace std;string solve(ll x, ll y, ll z) {const int limit = 10000;repeat_from (b, -limit/2, limit/2+1) {int a = (z - y*b) / x;if (a*x + y*b == z) {string s;if (a > 0) {s += 'c'; -- a;} else if (b > 0) {s += 'w'; -- b;} else {s += "ccW";}if (s.length() + 2*abs(a) + 2*abs(b) > limit) continue;repeat (i, abs(a)) (s += 'c') += (a > 0 ? 'C' : 'W');repeat (i, abs(b)) (s += 'w') += (b > 0 ? 'C' : 'W');return s;}}return "";}int main() {int x, y, z; cin >> x >> y >> z;int gcd = __gcd(x, y);string ans;if (z % gcd == 0) ans = solve(x / gcd, y / gcd, z / gcd);if (ans.empty()) ans = "mourennaihasimasenn";cout << ans << endl;return 0;}