結果

問題 No.405 ローマ数字の腕時計
ユーザー NoiriNoiri
提出日時 2017-12-09 23:27:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,183 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 61,244 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 12:43:01
合計ジャッジ時間 1,254 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:15: warning: ‘num’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     else if(t - num <= 0) num = 12 - (t - num);
      |             ~~^~~~~

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int t, num;
    string s;
    cin >> s >> t;

    if(s == "I") num = 1;
    else if(s == "II") num = 2;
    else if(s == "III") num = 3;
    else if(s == "IIII") num = 4;
    else if(s == "V") num = 5;
    else if(s == "VI") num = 6;
    else if(s == "VII") num = 7;
    else if(s == "VIII") num = 8;
    else if(s == "IX") num = 9;
    else if(s == "X") num = 10;
    else if(s == "XI") num = 11;
    else if(s == "XII") num = 12;

    t = abs(t) % 12;
    if(t + num > 12) num = t + num -12;
    else if(t - num <= 0) num = 12 - (t - num);

    if(num == 1) cout << "I" << endl;
    else if(num == 2) cout << "II" << endl;
    else if(num == 3) cout << "III" << endl;
    else if(num == 4) cout << "IIII" << endl;
    else if(num == 5) cout << "V" << endl;
    else if(num == 6) cout << "VI" << endl;
    else if(num == 7) cout << "VII" << endl;
    else if(num == 8) cout << "VIII" << endl;
    else if(num == 9) cout << "IX" << endl;
    else if(num == 10) cout << "X" << endl;
    else if(num == 11) cout << "XI" << endl;
    else if(num == 12) cout << "XII" << endl;

    return 0;
}
0