結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-03 15:51:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 566 bytes |
| コンパイル時間 | 649 ms |
| コンパイル使用メモリ | 69,832 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 16:01:25 |
| 合計ジャッジ時間 | 3,083 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 WA * 61 |
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll x = 1e9 + 1;
int main(){
ll n;
cin >> n;
int ans = 0;
ll up = 1;
while(up*up < n/x) up *= 10;
ll tmp = 0;
for(int i = 0; i < 9; i++){
tmp += x;
if(tmp <= n) ans++;
}
for(ll i = 1; i <= up; i++){
string s = to_string(i);
string t = s;
reverse(t.begin(), t.end());
s += t;
ll j = stoll(s);
if(j <= n/x) ans++;
}
cout << ans << endl;
return 0;
}