結果

問題 No.405 ローマ数字の腕時計
ユーザー xuelei
提出日時 2018-07-18 17:15:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 168,528 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-15 05:37:24
合計ジャッジ時間 2,629 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:18:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   18 |   }else ans=(ans+t)%12;
      |             ~~~~^~~
main.cpp:6:9: note: 'ans' was declared here
    6 |   int t,ans;
      |         ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  int t,ans;
  cin >> s >> t;
  string clock[13]={"error","I","II","III","IIII","V","VI","VII","VIII","IX","X","XI","XII"};
  for(int i=1;i<13;i++){
    if(s==clock[i])ans=i;
  }
  if(t<0){
    t=-t;
    for(int i=0;i<t%12;i++){
      ans--;
      if(ans==0)ans+=12;
    }
  }else ans=(ans+t)%12;
  cout << clock[ans] << endl;
}
0