結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
![]() |
提出日時 | 2016-05-04 23:02:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,931 bytes |
コンパイル時間 | 1,930 ms |
コンパイル使用メモリ | 167,604 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 21:40:40 |
合計ジャッジ時間 | 5,396 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 98 |
ソースコード
/** Problem link* http://yukicoder.me/problems/1100*/#include<bits/stdc++.h>using namespace std;struct INIT{INIT(){cin.tie(0);ios_base::sync_with_stdio(false);} }init;typedef long long LL;inline bool inner(LL x,LL lb,LL ub) {return(lb <= x && x <= ub);}#define SZ 10000int main() {LL x, y, z;cin >> x >> y >> z;assert(inner(x, 0, 100000000));assert(inner(y, 0, 100000000));assert(inner(z, 0, 100000000));/*多分分けなくてもいいけどz=0は分けたほうが楽だと思います.*/if (z == 0)cout << "ccW" << endl;/*これは分けないと多分事故る*/else if (x == 0 && y ==0)cout << "NO" << endl;else if (x == 0) {if (z%y == 0 && (z / y) * 2 - 1 <= SZ) {for (int i = 0; i < (z / y); i++)cout << 'w';for (int i = 1; i < (z / y); i++)cout << 'C';cout << endl;}elsecout << "NO" << endl;}else if (y == 0) {if (z%x == 0 && (z / x) * 2 - 1 <= SZ) {for (int i = 0; i < (z / x); i++)cout << 'c';for (int i = 1; i < (z / x); i++)cout << 'C';cout << endl;}elsecout << "NO" << endl;}else {for (int n = 1; n <= 5000; n++) {if ((z - n * x) % y == 0 && abs((z - n * x) / y) * 2 + n * 2 - 1 <= SZ) {for (int i = 0; i < abs((z - n * x) / y); i++)cout << 'w';for (int i = 0; i < n; i++)cout << 'c';for (int i = 1; i < n; i++)cout << 'C';for (int i = 0; i < abs((z - n * x) / y); i++)if (z - n*x < 0)cout << 'W';else cout << 'C';cout << endl;return 0;}if ((z - n * y) % x == 0 && abs((z - n * y) / x) * 2 + n * 2 - 1 <= SZ) {for (int i = 0; i < abs((z - n * y) / x); i++)cout << 'c';for (int i = 0; i < n; i++)cout << 'w';for (int i = 1; i < n; i++)cout << 'C';for (int i = 0; i < abs((z - n * y) / x); i++)if (z - n*y < 0)cout << 'W';else cout << 'C';cout << endl;return 0;}}cout << "NO" << endl;}return 0;}