結果

問題 No.438 Cwwプログラミング入門
ユーザー butter_rollbutter_roll
提出日時 2016-10-29 04:59:30
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 60,224 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 23:04:54
合計ジャッジ時間 9,432 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54 WA * 39 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <typeinfo>
using namespace std;



int main(void){
  
  int i,l,r,k,t,j,tmp;
  int x,y,z;
  int a,b;
  int am,bm;

  cin>>x>>y>>z;
  a=-1;
  for(i=0;i<=5000;i++){
    if((z-i*x)%y==0) {a=i; goto L;}
  }
  for(i=0;i>=-5000;i--){
    if((z-i*x)%y==0) {a=i; break;}
  }

 L:

  if(a==-1) {
    cout<<"mourennaihasimasenn"<<endl;
    return 0;
  }

  b=(z-a*x)/y;
  am=1;bm=1;
  if(a<0) am=-1;
  if(b<0) bm=-1;

  a=abs(a);  
  b=abs(b);  
  
  j=0;k=0;
  if(a!=0) {
    cout<<"c";
    j=1;
  }
  else if(b!=0) {
    cout<<"w";
    k=1;
  }
  
  for(i=1;i<2*a+2*b-1;i++){
    if(j<a){
      cout<<"c";
      if(am==-1) cout<<"W";
      else cout<<"C";
      j++;
    }
    else if(k<b){
      cout<<"w";
      if(bm==-1) cout<<"W";
      else cout<<"C";
      k++;
    }
  }
  cout<<endl;
  return 0;
}
0