結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:58:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 927 bytes |
コンパイル時間 | 1,804 ms |
コンパイル使用メモリ | 171,112 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 08:22:21 |
合計ジャッジ時間 | 4,449 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 103 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for (int i=0;i<(n);i++)#define rep2(i,a,b) for (int i=(a);i<(b);i++)#define rrep(i,n) for (int i=(n)-1;i>=0;i--)#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)#define all(a) (a).begin(),(a).end()const bool DEBUG = false;#define dump(a) if (DEBUG) cout << (a) << endl;typedef long long ll;typedef pair<int, int> P;ll N;void solve() {ll p = (ll)1e9 + 1;ll count = 0;cin >> N;rep2(n, 1, 10) {if (N >= n * p) {dump(n);count++;}}rep2(i, 1, (int)1e4) {string s1, s2;s1 = s2 = to_string(i);reverse(all(s2));ll n = stoll(s1 + s2);if (N >= n * p) {dump(n);count++;}rep(i, 10) {ll n = stoll(s1 + to_string(i) + s2);if (N >= n * p) {dump(n);count++;}}}cout << count << endl;}int main() {solve();return 0;}