結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-05-16 16:23:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 1,000 ms |
| コード長 | 1,752 bytes |
| コンパイル時間 | 2,654 ms |
| コンパイル使用メモリ | 197,576 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-05-16 16:23:07 |
| 合計ジャッジ時間 | 4,861 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 103 |
ソースコード
/*
??????
??????
??????
??????
D P ????
??????
??????
??????
??????
??? l l?
??????
??????
?? OI ??
??????
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define eps 1e-9
//#define ENF 1e13
const int N=1e1;
const int mod=1e9+7;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
return x*f;
}
void write(int x)
{
if(x<0)putchar('-'),x=-x;
if(x<10)putchar(x+'0');
else write(x/10),putchar(x%10+'0');
}
int ans;
int n;
void cal(int x){
vector<int>sm;
while(x){
sm.push_back(x%10);
x/=10;
}
reverse(sm.begin(),sm.end());
int top=sm.size();
for(int i=top+1;i<=top*2;i++)sm.push_back(sm[2*top-i]);
int u=0;
for(int i=1;i<=top*2;i++)u*=10,u+=sm[i-1];
if(u<=n){
ans++;
for(int i=0;i<=9;i++){
u=0;
for(int j=1;j<=top;j++)u*=10,u+=sm[j-1];
u*=10;
u+=i;
for(int j=top+1;j<=top*2;j++)u*=10,u+=sm[j-1];
if(u<=n)ans++;
}
}
top=0;
return;
}
signed main(){
// freopen("palindrome.in","r",stdin);
// freopen("palindrome.out","w",stdout);
n=read();
n/=1000000001;
int u=n;
int sum=0;
while(u){
sum++;
u/=10;
}
sum>>=1;
sum++;
int k=1;
for(int i=1;i<=sum;i++)k*=10;
if(n>10){
ans+=9;
}
else{
ans+=n;
cout<<ans<<"\n";
return 0;
}
for(int i=1;i<=k;i++){
cal(i);
}
cout<<ans<<"\n";
return 0;
}
// ?????????????AC????
// ?????????????????????????
// ??????????????????
// ????????????????????????????????????
// ???????????????????????????????
// ????????????
// ????????????
// ????????????
// ????????????????????
// ????????????????????
// ????????????????????????????????
// ???????????????????????
// ???????????
// ?????????????
vjudge1