結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:38:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 1,000 ms |
コード長 | 1,167 bytes |
コンパイル時間 | 610 ms |
コンパイル使用メモリ | 80,588 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 08:20:32 |
合計ジャッジ時間 | 3,176 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 103 |
ソースコード
#include <iostream>#include <fstream>#include <cstdio>#include <cmath>#include <vector>#include <cstring>#include <string>#include <set>#include <map>#include <stack>#include <queue>#include <algorithm>using namespace std;#define REP(i,n) for(int i=0; i<n; ++i)#define FOR(i,a,b) for(int i=a; i<=b; ++i)#define FORR(i,a,b) for (int i=a; i>=b; --i)#define ALL(c) (c).begin(), (c).end()typedef long long ll;typedef vector<int> VI;typedef vector<ll> VL;typedef vector<VI> VVI;typedef pair<int,int> P;typedef pair<ll,ll> PL;ll powll(ll x, ll y){if (y == 0) return 1;return x * powll(x, y-1);}int main() {ll n;cin >> n;int ans = 0;FOR(i,1,9){int lim = powll(10,(i+1)/2);FOR(p,1,lim-1){if (p % 10 == 0) continue;ll x = p, y = p;REP(a,i/2){x += (y%10)*powll(10,i-a-1);y /= 10;}// cout << x << endl;x += x*powll(10,9);// cout << x<< endl;if (x <= n){ans++;}}}cout << ans << endl;return 0;}