結果
問題 | No.405 ローマ数字の腕時計 |
ユーザー |
![]() |
提出日時 | 2016-08-05 22:40:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 793 ms |
コンパイル使用メモリ | 91,744 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 18:59:31 |
合計ジャッジ時間 | 1,542 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%s %d", str,&t); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <stack> using namespace std; #define Getsign(n) ((n > 0) - (n < 0)) #define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ? true : false) map<string, int> roma_time = { { "I",1 },{ "II",2 },{ "III",3 },{ "IIII",4 },{ "V",5 },{ "VI",6 },{ "VII",7 },{ "VIII",8 },{ "IX",9 },{ "X",10 },{ "XI",11 },{ "XII",12 } }; typedef vector<int> Ivec; typedef pair<int, int> pii; int main() { char str[5]; int t; scanf("%s %d", str,&t); int time = (t + roma_time[(string) str]) % 12; if (time < 0) time = 12 - abs(time); if (time == 0) time = 12; for (auto itr = roma_time.begin(); itr != roma_time.end(); itr++) { if(itr->second == time) printf("%s\n", itr->first.c_str()); } return 0; }