結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-10-29 00:16:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,462 bytes |
コンパイル時間 | 796 ms |
コンパイル使用メモリ | 82,820 KB |
実行使用メモリ | 1,515,964 KB |
最終ジャッジ日時 | 2024-11-24 22:21:22 |
合計ジャッジ時間 | 88,851 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 MLE * 1 |
other | AC * 30 WA * 32 RE * 2 TLE * 7 MLE * 15 OLE * 12 |
ソースコード
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define pi acos(-1.0) typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VI> VVI; typedef pair<int,int> P; typedef pair<ll,ll> PL; int gcd(int a, int b){ if (b == 0) return a; return gcd(b, a % b); } 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(){ int x, y, z; cin >> x >> y >> z; int d = gcd(x,y); if (z % d != 0){ cout << "mourennaihasimasenn" << endl; return 0; } x /= d; y /= d; z /= d; int p, q; extgcd(x, y, p, q); p *= z; q *= z; string s1, s2; REP(i,abs(p)) s1 += 'c'; REP(i,abs(p)-1) s1 += 'C'; REP(i,abs(q)) s2 += 'w'; REP(i,abs(q)-1) s2 += 'C'; if (p == 0) cout << s2 << endl; else if (q == 0) cout << s1 << endl; else if (p > 0 && q > 0) cout << s1 + s2 + 'C' << endl; else if (p < 0) cout << s2 + s1 + 'W' << endl; else cout << s1 + s2 + 'W' << endl; return 0; }