結果

問題 No.438 Cwwプログラミング入門
ユーザー nasadigitalnasadigital
提出日時 2016-10-30 14:10:21
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,990 bytes
コンパイル時間 1,478 ms
コンパイル使用メモリ 159,088 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 23:35:34
合計ジャッジ時間 8,935 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

void print(char f,char s,int a,int b,bool del){
    for(int ctr1=0;ctr1<a;ctr1++)
        cout<<f;
    for(int ctr1=0;ctr1<b;ctr1++)
        cout<<s;
    if(del){
        for(int ctr1=1;ctr1<b;ctr1++)
            cout<<'C';
        if(b>=1)
            cout<<'W';
        for(int ctr1=1;ctr1<a;ctr1++)
            cout<<'C';
    }
    else{
        for(int ctr1=1;ctr1<a+b;ctr1++)
            cout<<'C';
    }
}


int main()
{
    ll x,y,z;
    cin>>x>>y>>z;
    if(z==0){
        cout<<"ccW";
        return 0;
    }
    if(x==0 && y==0){
        cout<<"NO";
        return 0;
    }
    if(x==0){
        if(z%y)
        cout<<"NO";
        else if(z/y<=5000)
        print('w','c',z/y,0,false);
        return 0;
    }
    if(y==0){
        if(z%x)
        cout<<"NO";
        else if(z/x<=5000)
        print('c','w',z/x,0,false);
        return 0;
    }
    ll t,t2;
    for(int ctr1=1;ctr1<=5000;ctr1++){
        t=z-x*ctr1;
        if(t<0){
            t=-t;
            if(t%y==0){
                t2=t/y;
                if(ctr1+t2<=5000){
                    print('c','w',ctr1,t2,true);
                    return 0;
                }
            }
        }
        else if(t%y==0){
            t2=t/y;
            if(ctr1+t2<=5000){
                print('c','w',ctr1,t2,false);
                return 0;
            }
        }
    }
    swap(x,y);
    for(int ctr1=1;ctr1<=5000;ctr1++){
        t=z-x*ctr1;
        if(t<0){
            t=-t;
            if(t%y==0){
                t2=t/y;
                if(ctr1+t2<=5000){
                    print('w','c',ctr1,t2,true);
                    return 0;
                }
            }
        }
        else if(t%y==0){
            t2=t/y;
            if(ctr1+t2<=5000){
                print('w','c',ctr1,t2,false);
                return 0;
            }
        }
    }
    cout<<"NO";
    return 0;
}
0