結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:40:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,010 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 172,796 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 09:01:47 |
合計ジャッジ時間 | 4,891 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 28 WA * 75 |
ソースコード
#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; bool is_palindrome(ll n) { string s1, s2; s1 = s2 = to_string(n); reverse(all(s2)); return s1 == s2; } ll make_palindrome(int i) { string s1, s2; s1 = s2 = to_string(i); reverse(all(s2)); return stoll(s1 + s2); } void solve() { ll p = (ll)1e9 + 1; ll count = 0; cin >> N; ll max_n = ((N / p) * p) % (ll)1e9; dump(max_n); rep2(n, 1, 10) { if (max_n > n) { dump(n); count++; } } rep2(i, 1, (ll)1e5) { ll n = make_palindrome(i); if (max_n > n) { dump(n); count++; } } cout << count << endl; } int main() { solve(); return 0; }