結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
|
提出日時 | 2019-02-12 11:57:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,344 bytes |
コンパイル時間 | 528 ms |
コンパイル使用メモリ | 65,256 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 09:36:56 |
合計ジャッジ時間 | 4,498 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 96 WA * 1 RE * 1 |
ソースコード
#include<iostream> using namespace std; typedef long long ll; void answer(ll a, ll b){ int add = 0, sub = 0; if(a < 0){ for(int i = 0; i < abs(a); i++) cout << "c"; sub += (int)abs(a); } if(b < 0){ for(int i = 0; i < abs(b); i++) cout << "w"; sub += (int)abs(b); } if(a > 0){ for(int i = 0; i < abs(a); i++) cout << "c"; add += (int)abs(a)-1; } if(b > 0){ for(int i = 0; i < abs(b); i++) cout << "w"; add += (int)abs(b)-1; } while(add-- > 0) cout << "C"; while(sub-- > 0) cout << "W"; cout << endl; } int main(){ int x, y, z; cin >> x >> y >> z; if(z == 0){ cout << "ccW" << endl; return 0; } if(x == 0 || y == 0){ if(z%(max(x,y)) > 0 || z/(max(x,y)) > 5000) cout << "NO" << endl; else{ char c = x > y ? 'c' : 'w'; for(int i = 0; i < z/max(x,y); i++) cout << c; for(int i = 1; i < z/max(x,y); i++) cout << "C"; cout << endl; } return 0; } for(ll a = -5000; a <= 5000; a++){ if(abs(z-a*x)%y) continue; if(2*abs(a) + 2*(abs(z-a*x)/y) - 1 <= 10000){ answer(a, (z-a*x)/y); return 0; } } cout << "NO" << endl; return 0; }