結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
|
提出日時 | 2016-10-28 23:46:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,387 bytes |
コンパイル時間 | 1,475 ms |
コンパイル使用メモリ | 168,068 KB |
実行使用メモリ | 813,572 KB |
最終ジャッジ日時 | 2024-11-24 21:01:15 |
合計ジャッジ時間 | 57,706 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 35 WA * 42 RE * 2 TLE * 12 MLE * 2 OLE * 5 |
ソースコード
#include<bits/stdc++.h> using namespace std; int extgcd(int a, int b, int &x, int &y) { int d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } int main() { cin.tie(0); ios::sync_with_stdio(false); int a, b, c; cin >> a >> b >> c; int x, y; int d = extgcd(a, b, x, y); string s = ""; if (c % d != 0) s = "mourennaihasimasenn"; else { x *= c / d; y *= c / d; if (x + y > 5000) s = "mourennaihasimasenn"; else { if (x < 0) { x = -x; for (int i = 0; i < y; i++) s += "w"; for (int i = 0; i < y - 1; i++) s += "C"; for (int i = 0; i < x; i++) s += "c"; for (int i = 0; i < x; i++) s += "W"; } else { for (int i = 0; i < x; i++) s += "c"; for (int i = 0; i < x - 1; i++) s += "C"; if (y < 0) { y = -y; for (int i = 0; i < y; i++) s += "w"; for (int i = 0; i < y; i++) s += "W"; } else { for (int i = 0; i < y; i++) s += "w"; for (int i = 0; i < y; i++) s += "C"; } } } } cout << s << endl; return 0; }