結果
| 問題 |
No.491 10^9+1と回文
|
| ユーザー |
mogurocker
|
| 提出日時 | 2017-10-16 18:03:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 894 bytes |
| コンパイル時間 | 1,349 ms |
| コンパイル使用メモリ | 162,328 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-11-17 20:58:18 |
| 合計ジャッジ時間 | 23,850 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 92 RE * 1 TLE * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;
ll x;
int num(int sz) {
return 9 * pow(10, (sz-10)/2);
}
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(false);
cin >> x;
if (x < 1000000001) {
cout << 0 << endl;
return 0;
}
string s = to_string(x);
int n = s.size();
int ret = 0;
for (int i = 10; i < n; i++) ret += num(i);
for (int i = pow(10, n-10); i < pow(10, n-9); i++) {
string t = to_string(i);
int nn = t.size();
bool ok = true;
FOR(j, nn) {
if (t[j] != t[nn-j-1]) ok = false;
}
if (!ok) continue;
string tt = t + string(n-2*nn, '0') + t;
if (stoll(tt) > x) break;
ret++;
}
cout << ret << endl;
return 0;
}
mogurocker