結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
![]() |
提出日時 | 2017-03-08 13:26:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 69,980 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 19:19:45 |
合計ジャッジ時間 | 3,833 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 85 |
ソースコード
#include <string> #include <iostream> #include <algorithm> using namespace std; int solve(int x) { int ret = 0; for (int i = 1; i <= 9; i++) { if (i <= x) ret++; } for (int i = 1; i < 10000; i++) { string t1 = to_string(i), t2 = t1; reverse(t1.begin(), t1.end()); if (stoi(t1 + t2) <= x) ret++; for (int j = 0; j <= 9; j++) { if (stoi(t1 + to_string(j) + t2) <= x) ret++; } } return ret; } long long n; int main() { cin >> n; int x = 1000000000; int p = n / x, q = n % x; cout << solve(p - 1) + (q >= p) << endl; return 0; }