結果
問題 |
No.164 ちっちゃくないよ!!
|
ユーザー |
![]() |
提出日時 | 2015-09-15 01:25:24 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 415 ms |
コンパイル使用メモリ | 59,612 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 14:18:06 |
合計ジャッジ時間 | 893 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:14:30: warning: integer overflow in expression of type ‘long long int’ results in ‘9223372036854775807’ [-Woverflow] 14 | LL ans = (1LL << 63) - 1; | ~~~~~~~~~~~~^~~
ソースコード
#include <iostream> #include <algorithm> #include <sstream> #include <cstdio> using namespace std; typedef long long LL; int main(int argc, char *argv[]) { string s; getline(cin, s); int N = atoi(s.c_str()); LL ans = (1LL << 63) - 1; for (int i = 0; i < N; ++i) { getline(cin, s); char m = *max_element(s.begin(), s.end()); LL x = m - '0' + 1; if (x > 10) { x = m - 'A' + 11; } LL v = 0; for (char c : s) { v *= x; LL a = c - '0'; if (a > 9) { a = c - 'A' + 10; } v += a; } ans = min(ans, v); } cout << ans << endl; return 0; }