結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-10-28 22:53:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,815 bytes |
コンパイル時間 | 1,127 ms |
コンパイル使用メモリ | 111,896 KB |
実行使用メモリ | 7,184 KB |
最終ジャッジ日時 | 2024-11-24 18:29:12 |
合計ジャッジ時間 | 11,246 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 32 WA * 61 RE * 5 |
ソースコード
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cctype> #include <cstring> #include <ctime> #include <iterator> #include <bitset> #include <numeric> #include <list> #include <iomanip> #include <cassert> #include <array> #include <tuple> #include <initializer_list> #include <unordered_set> #include <unordered_map> #include <forward_list> using namespace std; using ll = long long; #define rep(i,n) for(int i = 0; i < (int)(n); ++i) ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } ll extgcd(ll a, ll b, ll c, ll& x, ll& y) { ll g = a; x = c / a; y = 0; if (b) g = extgcd(b, a%b, c%b, y, x), y += (c / b) - (a / b) * x; return g; } string solve(ll x, ll y, ll z) { //if (x < y) swap(x, y); if (z % gcd(x, y) != 0) { return "mourennaihasimasenn"; } // xc + yw = z ll c, w; extgcd(x, y, z, c, w); if (abs(x) + abs(y) > 10000) { return "mourennaihasimasenn"; } string res; while (c > 0) { if (res == "") { res += 'c'; } res += 'c'; res += 'C'; --c; } while (w > 0) { if (res == "") { res += 'w'; } res += 'w'; res += 'C'; --w; } while (c < 0) { res += 'c'; res += 'W'; ++c; } while (w < 0) { res += 'w'; res += 'W'; ++w; } return res; } int main() { ll x, y, z; while (cin >> x >> y >> z) { cout << solve(x, y, z) << endl; } }