結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
Bantako
|
| 提出日時 | 2017-08-23 20:46:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,018 bytes |
| コンパイル時間 | 1,558 ms |
| コンパイル使用メモリ | 168,648 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-15 13:08:30 |
| 合計ジャッジ時間 | 17,619 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 RE * 56 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main(){
| ^~~~
ソースコード
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
if(!b)return a;
return gcd(b,a%b);
}
main(){
ll x,y,z;
cin >> x >> y >> z;
if(z % gcd(x,y)){
cout << "NO" << endl;
return 0;
}
int min = INF;
pair<int,int> ans;
for(int i = 0;i < 100;i++){
for(int j = 0;j < 100;j++){
if(x*i + y*j == z)if(abs(i)+abs(j) < min){
min = abs(i)+abs(j);
ans = make_pair(i,j);
}
}
}
int a = ans.first,b = ans.second;
if(a < b || a == 0){
cout << string(abs(b),'w') << string(abs(b)-1,'C');
if(a == 0)return 0;
cout << string(abs(a),'c') << string(abs(a)-1,'C');
cout << (b<0?"W":"C") << endl;
}else{
cout << string(abs(a),'c') << string(abs(a)-1,'C');
if(b == 0)return 0;
cout << string(abs(b),'w') << string(abs(b)-1,'C');
cout << (a<0?"W":"C") << endl;
}
}
Bantako