結果
| 問題 |
No.405 ローマ数字の腕時計
|
| コンテスト | |
| ユーザー |
daradara_sanma
|
| 提出日時 | 2018-04-30 11:54:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 729 bytes |
| コンパイル時間 | 1,913 ms |
| コンパイル使用メモリ | 54,592 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 23:50:15 |
| 合計ジャッジ時間 | 1,249 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%s %d",S1, &T1);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
int T1, T2 = 0, i = 0;
char S1[5], result[5];
scanf("%s %d",S1, &T1);
T1 = T1 % 12;
for ( i = 0; i < strlen(S1); i++)
{
if (S1 == "IX") {
T2 = 9;
break;
}
if (S1[i] == 'I') T2++;
if (S1[i] == 'V') T2 += 5;
if (S1[i] == 'X') T2 += 10;
}
i = 0;
T2 = (T2 + T1) % 12;
if (T2 < 0) T2 += 12;
if (T2 / 10 != 0)
{
result[i++] = 'X';
T2 %= 10;
}
if (T2 == 9) {
printf("IV\n");
return 0;
}
if (T2 / 5 != 0)
{
result[i++] = 'V';
T2 %= 5;
}
if (T2 <= 4) {
for (int k = 0; k < T2; k++)
{
result[i++] = 'I';
}
}
result[i] = '\0';
printf("%s\n", result);
return 0;
}
daradara_sanma