結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
|
提出日時 | 2016-10-29 00:21:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,814 bytes |
コンパイル時間 | 1,985 ms |
コンパイル使用メモリ | 168,392 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 22:31:27 |
合計ジャッジ時間 | 6,318 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 93 WA * 5 |
ソースコード
#include<bits/stdc++.h> using namespace std; int a, b, c; bool solve(int &x, int &y) { for (int i = 0; i <= 5000; i++) { for (int j = 0; j <= 5000 - i; j++) { if (a * i + b * j == c) { x = i; y = j; return true; } if (-a * i + b * j == c) { x = -i; y = j; return true; } if (a * i - b * j == c) { x = i; y = -j; return true; } } } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; int x, y; string s = ""; if (!solve(x, y)) s = "mourennaihasimasenn"; else { if (x < 0) { x = -x; for (int i = 0; i < x; i++) s += "c"; for (int i = 0; i < x - 1; i++) s += "C"; for (int i = 0; i < y; i++) s += "w"; for (int i = 0; i < y - 1; i++) s += "C"; s += "W"; } else { if (y < 0) { y = -y; 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 - 1; i++) s += "C"; s += "W"; } else { for (int i = 0; i < x; i++) s += "c"; for (int i = 0; i < x - 1; i++) s += "C"; for (int i = 0; i < y; i++) s += "w"; for (int i = 0; i < y - 1; i++) s += "C"; if (x != 0 && y != 0) s += "C"; } } } cout << s << endl; return 0; }