結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-11 09:21:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 1,000 ms |
コード長 | 1,273 bytes |
コンパイル時間 | 1,934 ms |
コンパイル使用メモリ | 175,232 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 08:30:01 |
合計ジャッジ時間 | 7,917 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 103 |
ソースコード
#include <bits/stdc++.h>#define REP(i, x, n) for (int i = x; i < (int)(n); i++)#define rep(i, n) REP (i, 0, n)#define all(x) (x).begin(), (x).end()#define rall(x) (x).rbegin(), (x).rend()#define sz(x) (int)(x.size())#define popcount(x) __builtin_popcount(x)#define popcountll(x) __builtin_popcountll(x)#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())#define F first#define S second#define mp make_pair#define eb emplace_backusing namespace std;typedef long long ll;typedef unsigned long long ull;const int INF = 1 << 29;vector<ll> plist;ll toll(string s) {ll res = 0;rep (i, s.size()) {res = res * 10 + (int)(s[i] - '0');}return res;}void dfs(string p) {if (p.size() > 9) return;if (p.size() != 0 && p[0] != '0') {plist.push_back(toll(p));}rep (i, 10) {string c = string(1, (char)('0' + i));dfs(c + p + c);}}int main() {ull n;cin >> n;// evendfs("");// oddrep (i, 10) {dfs(string(1, (char)('0' + i)));}sort(all(plist));int ans = 0;rep (i, plist.size()) {ull v = (ull) 1e9 * plist[i] + plist[i];if (v <= n) ans++;else break;}cout << ans << endl;}