結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 22:51:05 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 911 bytes |
コンパイル時間 | 1,317 ms |
コンパイル使用メモリ | 159,016 KB |
実行使用メモリ | 13,884 KB |
最終ジャッジ日時 | 2024-06-24 08:26:46 |
合計ジャッジ時間 | 5,405 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 2 -- * 99 |
ソースコード
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) #define repr(i,n) for(int i=(n)-1;0<=i;--i) #define each(e,v) for(auto&& e:(v)) #define DUMP(x) cerr<<#x<<": "<<(x)<<endl #define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl using namespace std; using vint = vector<int>; using vdouble = vector<double>; using vstring = vector<string>; using ll = long long; template <class T> void chmin(T& a, const T& b) { a = min(a, b); } template <class T> void chmax(T& a, const T& b) { a = max(a, b); } constexpr ll M = 1e9 + 1; bool isPalindrome(string str) { const int s = str.size(); rep(i, s/2) { if(str[i] != str[s-i-1]) return false; } return true; } int main() { ll n; cin >> n; int cnt = 0; for(ll a = M; a <= n; a += M) { if(isPalindrome(to_string(a))) cnt++; } cout << cnt << endl; return 0; }