結果

問題 No.405 ローマ数字の腕時計
ユーザー okayunonahaokayunonaha
提出日時 2016-08-05 23:26:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,508 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 52,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 00:15:08
合計ジャッジ時間 1,443 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int solve(char *str, int t);

int main(void) {
  int t,n=0;
  char s[5];
  scanf("%s %d", s, &t);
  s[strlen(s)] = '\0';
  n = solve(s, t);
  //cout << n << endl;
  if(n < 0) n = n%12+12;
  if(n == 0) {
    cout <<  "XII"<< endl;
  } else if(n == 1) {
    cout << "I"<<endl;
  } else if(n == 2) {
    cout << "II"<<endl;
  } else if(n == 3) {
    cout << "III"<<endl;
  } else if(n == 4) {
    cout <<  "IIII"<<endl;
  } else if(n == 5) {
    cout<< "V"<<endl;
  } else if(n == 6) {
    cout<< "VI"<<endl;
  } else if(n == 7) {
    cout<< "VII"<<endl;
  } else if(n == 8) {
    cout<< "VIII"<<endl;
  } else if(n == 9) {
    cout<< "IX"<<endl;
  } else if(n == 10) {
    cout<< "X"<<endl;
  }else if(n == 11) {
    cout << "XI"<< endl;
  }

  return 0;
}

int solve(char *str, int t) {
  int n = 0;

  if (str[0] == 'I'&&str[1]=='\0') {
    n += 1+t;
  }else if(!strcmp(str,"II")) {
    n += 2+t;

  }else if(!strcmp(str, "III")) {
    n += 3+t;

  }else if (!strcmp(str, "IIII")) {
    n += 4+t;
	
  }else if(str[0] == 'V'&&str[1]=='\0') {
    n += 5+t;

  }else if(!strcmp(str, "VI")) {
    n += 6+t;
  }else if(!strcmp(str,"VII")) {
    n += 7+t;
  }else if(!strcmp(str,"VIII")) {
    n += 8+t;
  }else if(!strcmp(str,"IX")) {
    n += 9+t;
  }else if(str[0] == 'X'&& str[1] =='\0') {
    n += 10+t;
  }else if(!strcmp(str,"XI")) {
    n += 11+t;
  }else if(!strcmp(str, "XII")) {
    n += 12+t;
  }
  n %= 12;

  return n;
}
0