結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:14:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,062 bytes |
コンパイル時間 | 1,780 ms |
コンパイル使用メモリ | 170,664 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 08:34:45 |
合計ジャッジ時間 | 4,024 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; #define int ll #define FOR(i,a,b) for(int i=int(a);i<int(b);i++) #define REP(i,b) FOR(i,0,b) #define MP make_pair #define PB push_back #define ALL(x) x.begin(),x.end() #define REACH cerr<<"reached line "<<__LINE__<<endl #define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl using pi=pair<int,int>; using vi=vector<int>; using ld=long double; template<class T,class U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os<<"("<<p.first<<","<<p.second<<")"; return os; } template<class T> ostream& operator <<(ostream& os,const vector<T>& v){ os<<"["; REP(i,(int)v.size()){ if(i)os<<","; os<<v[i]; } os<<"]"; return os; } int read(){ int i; scanf("%lld",&i); return i; } void printSpace(){ printf(" "); } void printEoln(){ printf("\n"); } void print(int x,int suc=1){ printf("%lld",x); if(suc==1) printEoln(); if(suc==2) printSpace(); } string readString(){ static char buf[3341919]; scanf("%s",buf); return string(buf); } char* readCharArray(){ static char buf[3341919]; static int bufUsed=0; char* ret=buf+bufUsed; scanf("%s",ret); bufUsed+=strlen(ret)+1; return ret; } template<class T,class U> void chmax(T& a,U b){ if(a<b) a=b; } template<class T,class U> void chmin(T& a,U b){ if(a>b) a=b; } template<class T> T Sq(const T& t){ return t*t; } const int inf=LLONG_MAX/3; int Kyuri(int x){ int res=0; while(x){ res++; x/=10; } return res; } int reverse(int x){ vi d; while(x){ d.PB(x%10); x/=10; } int res=0; for(auto v:d){ res*=10; res+=v; } return res; } int pow10(int x){ int res=1; while(x--)res*=10; return res; } int check(int i,int h,int x,int d){ int t=i*pow10(d-h); if(h>d-h)i/=10; return t+reverse(i)<=x; } int Wafrelka(int x){ int d=Kyuri(x); int h=(d+1)/2,g=pow10(h); int res=0; FOR(i,1,g) res+=check(i,h,x,d); FOR(e,1,d) res+=pow10((e+1)/2)-1; return res; } signed main(){ int n=read(); int x=n/1000000000; if(x*1000000000+reverse(x)>n)x--; cout<<Wafrelka(x)<<endl; }