結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
![]() |
提出日時 | 2017-03-10 21:27:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 70,948 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 07:55:04 |
合計ジャッジ時間 | 4,264 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 77 |
ソースコード
#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(t2.begin(), t2.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; }