結果

問題 No.438 Cwwプログラミング入門
ユーザー tossytossy
提出日時 2016-10-29 13:13:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,410 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 90,436 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 23:07:42
合計ジャッジ時間 4,750 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 94 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(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){
        best = abs(tmp/y)+abs(a);
        bestA = a;
        bestB = tmp/y;
      }
    }
  }
  if( best==5001 || (x==0 && y==0 && z==0) ){
    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;
}
0