結果

問題 No.438 Cwwプログラミング入門
ユーザー face4
提出日時 2019-02-12 11:55:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,360 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 66,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 09:20:19
合計ジャッジ時間 4,626 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 94 WA * 3 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long ll;

void answer(ll a, ll b){
    int add = 0, sub = 0;
    if(a < 0){
        for(int i = 0; i < abs(a); i++) cout << "c";
        sub += (int)abs(a);
    }
    if(b < 0){
        for(int i = 0; i < abs(b); i++) cout << "w";
        sub += (int)abs(b);
    }
    if(a > 0){
        for(int i = 0; i < abs(a); i++) cout << "c";
        add += (int)abs(a)-1;
    }
    if(b > 0){
        for(int i = 0; i < abs(b); i++) cout << "w";
        add += (int)abs(b)-1;
    }
    while(add-- > 0)    cout << "C";
    while(sub-- > 0)    cout << "W";
    cout << endl;
}

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    if(x == 0 || y == 0){
        if(z == 0)  cout << "ccW" << endl;
        else{
            if(z%(max(x,y)) > 0 || z/(max(x,y)) > 5000)  cout << "NO" << endl;
            else{
                char c = x > y ? 'c' : 'w';
                for(int i = 0; i < z/max(x,y); i++)    cout << c;
                for(int i = 1; i < z/max(x,y); i++)    cout << "C";
                cout << endl;
            }
        }
        return 0;
    }

    for(ll a = -5000; a <= 5000; a++){
        if(abs(z-a*x)%y)   continue;
        if(2*abs(a) + 2*(abs(z-a*x)/y) - 1 <= 10000){
            answer(a, (z-a*x)/y);
            return 0;
        }
    }

    cout << "NO" << endl;
    
    return 0;
}
0