結果
問題 |
No.438 Cwwプログラミング入門
|
ユーザー |
![]() |
提出日時 | 2017-08-23 21:46:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 1,505 ms |
コンパイル使用メモリ | 170,720 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 13:17:11 |
合計ジャッジ時間 | 11,284 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 52 WA * 41 RE * 5 |
コンパイルメッセージ
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; } ll min = INF; pair<ll,ll> ans = make_pair(INF,INF); for(ll i = -100;i < 100;i++){ for(ll j = -100;j < 100;j++){ if(x*i + y*j == z)if(llabs(i)+llabs(j) < min){ min = llabs(i)+llabs(j); ans = make_pair(i,j); } } } ll a = ans.first,b = ans.second; if(llabs(a)*2+llabs(b)*2 > 20000){ cout << "NO" << endl; return 0; } string str; if(a < b || a == 0){ str += string(llabs(b),'w') + string(llabs(b)-1,'C'); if(a == 0)goto print; str += string(llabs(a),'c') + string(llabs(a)-1,'C'); str += (b<0?"W":"C"); }else{ str += string(llabs(a),'c') + string(llabs(a)-1,'C'); if(b == 0)goto print; str += string(llabs(b),'w') + string(llabs(b)-1,'C'); str += (a<0?"W":"C"); } print: if(str.length() > 10000)cout << "NO" << endl; else cout << str << endl; }