結果
| 問題 |
No.438 Cwwプログラミング入門
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2016-10-29 13:22:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,515 bytes |
| コンパイル時間 | 943 ms |
| コンパイル使用メモリ | 91,388 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-24 23:07:56 |
| 合計ジャッジ時間 | 4,591 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 96 WA * 2 |
ソースコード
#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 2147483600
int main(){
long x,y,z;
cin>>x>>y>>z;
int best=5001, bestA=0, bestB=0;
if(y==0){
if(z==0){
best=1;
bestB=1;
}
else 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;
}
tossy