結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
cherrypi59
|
| 提出日時 | 2019-04-15 11:38:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 454 bytes |
| コンパイル時間 | 1,450 ms |
| コンパイル使用メモリ | 167,728 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 07:49:47 |
| 合計ジャッジ時間 | 4,044 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 WA * 67 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
lint p[10];
int main(){
lint N; cin >> N;
N = N / lint(1e9+1) + 1;
string S = to_string(N);
p[0] = 1;
for(int i=1;i<10;i++) p[i] = p[i-1] * 10;
lint ans = 0, k = S.size();
for(int i=1;i<k;i++) ans += 9 * p[(i-1)/2];
for(int i=1;i<=(k+1)/2;i++) if(S[i-1]!='0')
ans += (S[i-1]-'1') * p[(k-2*i+1)/2];
cout << ans << endl;
return 0;
}
cherrypi59