結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-12 12:04:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,518 bytes |
| コンパイル時間 | 555 ms |
| コンパイル使用メモリ | 66,128 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 09:37:22 |
| 合計ジャッジ時間 | 10,084 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 47 WA * 51 |
ソースコード
#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);
}
if(b > 0){
for(int i = 0; i < abs(b); i++) cout << "w";
add += (int)abs(b);
}
if(sub == 0) add--;
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(x == 0 && y == 0){
if(z == 0) cout << "c" << endl;
else cout << "NO" << endl;
return 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;
}