結果

問題 No.438 Cwwプログラミング入門
ユーザー BantakoBantako
提出日時 2017-08-23 20:46:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,018 bytes
コンパイル時間 1,775 ms
コンパイル使用メモリ 166,244 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 13:12:18
合計ジャッジ時間 18,102 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 RE -
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 RE -
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 RE -
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 RE -
testcase_40 AC 2 ms
5,376 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 2 ms
5,376 KB
testcase_44 RE -
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 2 ms
5,376 KB
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 2 ms
5,376 KB
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 AC 2 ms
5,376 KB
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 AC 2 ms
5,376 KB
testcase_63 RE -
testcase_64 RE -
testcase_65 AC 2 ms
5,376 KB
testcase_66 RE -
testcase_67 AC 2 ms
5,376 KB
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 AC 2 ms
5,376 KB
testcase_80 RE -
testcase_81 AC 2 ms
5,376 KB
testcase_82 RE -
testcase_83 RE -
testcase_84 AC 2 ms
5,376 KB
testcase_85 AC 2 ms
5,376 KB
testcase_86 RE -
testcase_87 RE -
testcase_88 AC 2 ms
5,376 KB
testcase_89 RE -
testcase_90 RE -
testcase_91 RE -
testcase_92 RE -
testcase_93 RE -
testcase_94 RE -
testcase_95 RE -
testcase_96 RE -
testcase_97 RE -
testcase_98 AC 2 ms
5,376 KB
testcase_99 RE -
testcase_100 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
main(){
    ll x,y,z;
    cin >> x >> y >> z;
    if(z % gcd(x,y)){
        cout << "NO" << endl;
        return 0;
    }
    int min = INF;
    pair<int,int> ans;
    for(int i = 0;i < 100;i++){
        for(int j = 0;j < 100;j++){
            if(x*i + y*j == z)if(abs(i)+abs(j) < min){
                min = abs(i)+abs(j);
                ans = make_pair(i,j);
            }
        }
    }
    int a = ans.first,b = ans.second;
    if(a < b || a == 0){
        cout << string(abs(b),'w') << string(abs(b)-1,'C');
        if(a == 0)return 0;
        cout << string(abs(a),'c') << string(abs(a)-1,'C');
        cout << (b<0?"W":"C") << endl;
    }else{
        cout << string(abs(a),'c') << string(abs(a)-1,'C');
        if(b == 0)return 0;
        cout << string(abs(b),'w') << string(abs(b)-1,'C');
        cout << (a<0?"W":"C") << endl;
    }
}       
0