結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2016-10-29 20:55:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,791 bytes |
コンパイル時間 | 1,468 ms |
コンパイル使用メモリ | 175,020 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 21:22:51 |
合計ジャッジ時間 | 10,162 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 RE * 1 |
other | AC * 1 WA * 51 RE * 46 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) #define watch(a) { cout << #a << " = " << a << endl; } template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); } template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); } typedef long long ll; int const inf = 1<<29; ll x, y, z; namespace math { namespace integer { template<class value_type> value_type mod_mul(value_type x, value_type k, ll m) { if(k == 0) { return 0; } if(k % 2 == 0) { return mod_mul((x+x) % m, k/2, m); } else { return (x + mod_mul(x, k-1, m)) % m; } } template<class value_type> value_type mod_pow(value_type x, value_type n, ll mod) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(mod_mul(x, x, mod) % mod, n / 2, mod); } else { return mod_mul(x, mod_pow(x, n - 1, mod), mod); } } template<class value_type> value_type extgcd(value_type a, value_type b, value_type& x, value_type& y) { value_type d = a; if(b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; } template<class value_type> value_type mod_inverse(value_type x, ll mod) { return mod_pow(x, value_type(mod-2), mod); /* use fermat */ } template<class value_type> value_type mod_inverse_composite_num_mod(value_type a, ll mod) { value_type x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; } }} using namespace math::integer; const char* ng = "mourennaihasimasenn"; const int Lim = 10000; ll X, Y, g; /* void minimumShow(char c, ll x) { while(x > 0) { if(x & 1) { ans.push_back(c); } if(!ans.empty() && ans.back() == c) { ans += 'C'; } x >>= 1; } } */ bool verify(string& ans) { deque<ll> st; for(auto c: ans) { if(c == 'c') st.push_back(x); if(c == 'w') st.push_back(y); if(c == 'C') { if(st.empty()) return false; auto a = st.back(); st.pop_back(); if(st.empty()) return false; auto b = st.back(); st.pop_back(); st.push_back(a + b); } if(c == 'W') { if(st.empty()) return false; auto a = st.back(); st.pop_back(); if(st.empty()) return false; auto b = st.back(); st.pop_back(); st.push_back(a - b); } // for(auto e: st) cout << e << ", "; cout << endl; } if(st.size() != 1) return false; if(st.back() != z) return false; return true; } bool makeLast(string& ans) { int xp = 0, yp = 0; rep(i, -X) { ans += 'c'; if(X > 0) ans += 'c', xp++; else if(Y > 0) ans += 'w', yp++; ans += 'W'; } rep(i, -Y) { ans += 'w'; if(X > 0) ans += 'c', xp++; else if(Y > 0) ans += 'w', yp++; ans += 'W'; } rep(i, X - xp) ans += 'c'; rep(i, Y - yp) ans += 'w'; string t = ans; cout << "T = " << t << endl; rep(i, z / g - 1) ans += t; rep(i, z / g - 1) ans += 'C'; return true; } int main() { cin >> x >> y >> z; if(z == 0) return printf("ccW\n"); if(x == 0 || y == 0) return printf("%s", ng); for(int i=-5000; i<=5000; i++) { ll b = z - x * i; if(b % y) continue; ll c = b / y; if((abs(i) + abs(c)) * 2 - 1 > 10000) continue; if(i > 0 && c > 0) { cout << string(i, 'c') << string(c, 'w') << string(i + c - 1, 'C') << endl; return 0; } if(i < 0) { cout << string(abs(i), 'c') << string(abs(i) - 1, 'c') << string(c, 'w') << string(abs(c) - 1, 'C') << "W" << endl; return 0; } if(c < 0) { cout << string(abs(c), 'w') << string(abs(c) - 1, 'c') << string(abs(i), 'c') << string(abs(i) - 1, 'C') << "W" << endl; return 0; } } return printf("%s", ng); }