結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:14:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,474 bytes |
コンパイル時間 | 1,512 ms |
コンパイル使用メモリ | 169,296 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 07:10:42 |
合計ジャッジ時間 | 3,881 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 103 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long LL;#define CIN_ONLY if(1)struct cww{cww(){CIN_ONLY{ios::sync_with_stdio(false);cin.tie(0);}}}star;#define fin "\n"#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)#define REP(i,n) FOR(i,0,n)#define ALL(v) (v).begin(),(v).end()#define fi first#define se second#define pb push_back#define DEBUG if(0)#define REC(ret, ...) std::function<ret (__VA_ARGS__)>template <typename T>inline void chmin(T &l,T r){l=min(l,r);}template <typename T>inline void chmax(T &l,T r){l=max(l,r);}template <typename T>istream& operator>>(istream &is,vector<T> &v){for(auto &it:v)is>>it;return is;}template <typename ITR>bool next_value(int base,ITR bg,ITR ed){int c=1;for(; bg != ed && c==1; ++bg){(*bg)+=c;if((c = ((*bg) == base)))(*bg)=0;}return !c;}const LL B=1e9;int main(){LL N;cin>>N;int res=0;FOR(i,1,10)if(i*B+i<=N)res++;REP(len,4){vector<LL> x(len,0);do{FOR(i,1,10)REP(j,11){LL y=0;y=i;REP(k,len){y*=10;y+=x[k];}if(j<10){y*=10;y+=j;}REP(k,len){y*=10;y+=x[len-k-1];}y*=10;y+=i;y=y*B+y;if(y<=N)res++;// cout<<y<<endl;}}while(next_value(10,ALL(x)));}cout<<res<<endl;return 0;}