結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-23 09:27:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 1,000 ms |
| コード長 | 1,073 bytes |
| コンパイル時間 | 1,506 ms |
| コンパイル使用メモリ | 169,616 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 18:16:09 |
| 合計ジャッジ時間 | 4,663 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 103 |
ソースコード
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod= 1e10;
int main(){
ll N,ans=0;
cin>>N;
if(N<1e9+1){
p(0);
return 0;
}
for(ll i=1;i<=101000;i++){
string s = to_string(i);
int n = s.size();
ll x = 0;
REP(i, 0, n - 1) x = x * 10 + s[i] - '0';
x = x * 10 + s[n - 1] - '0';
REP(i, 0, n - 1) x = x * 10 + s[n - 2 - i] - '0';
ll a = x;
REP(i, 0, 9) a *= 10;
a += x;
if (0 <= a && a <= N) ans++;
ll xx = 0;
REP(i, 0, n) xx = xx * 10 + s[i] - '0';
REP(i, 0, n) xx = xx * 10 + s[n - 1 - i] - '0';
ll b = xx;
REP(i, 0, 9) b *= 10;
b += xx;
if (0 <= b && b <= N) ans++;
}
p(ans);
return 0;
}
dnish