結果
問題 | No.438 Cwwプログラミング入門 |
ユーザー |
![]() |
提出日時 | 2016-10-29 13:25:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,515 bytes |
コンパイル時間 | 1,701 ms |
コンパイル使用メモリ | 90,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 22:14:33 |
合計ジャッジ時間 | 3,711 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 98 |
ソースコード
#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <cassert>#include <iostream>#include <algorithm>#include <stack>#include <queue>#include <vector>#include <set>#include <map>#include <bitset>#include <functional>using namespace std;#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)#define rep(i,n) repl(i,0,n)#define mp(a,b) make_pair((a),(b))#define pb(a) push_back(a)#define all(x) (x).begin(),(x).end()#define dbg(x) cout<<#x"="<<(x)<<endl#define fi first#define se second#define INF 2147483600int main(){long x,y,z;cin>>x>>y>>z;int best=5001, bestA=0, bestB=0;if(z==0){cout<<"ccW"<<endl;return 0;} else if(y==0){if(x!=0 && z%x==0){bestA = z/x;best = z/x;}} else {for(long a=5000; a>=-5000; a--){long tmp = z - a*x;if(tmp%y==0 && abs(tmp/y)+abs(a)<best){if(a==0 && tmp/y==0) continue;best = abs(tmp/y)+abs(a);bestA = a;bestB = tmp/y;}}}// dbg(best);dbg(bestA);dbg(bestB);if( best==5001 ){cout<<"mourennaihasimasenn"<<endl;return 0;}int p=-1,m=0;if(bestA<0){rep(i,-bestA) printf("c");m += -bestA;}if(bestB<0){rep(i,-bestB) printf("w");m += -bestB;}if(bestA>0){rep(i, bestA) printf("c");p += bestA;}if(bestB>0){rep(i, bestB) printf("w");p += bestB;}rep(i, p) printf("%c", 'C');rep(i, m) printf("%c", 'W');printf("\n");return 0;}