結果
| 問題 | No.491 10^9+1と回文 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-04-01 20:17:02 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 1,000 ms | 
| コード長 | 1,016 bytes | 
| コンパイル時間 | 953 ms | 
| コンパイル使用メモリ | 104,880 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-01 08:40:48 | 
| 合計ジャッジ時間 | 4,887 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 103 | 
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<100000; ++i){
        string a = to_string(i);
        string b = a;
        reverse(b.begin(), b.end());
        for(int j=0; j<2; ++j){
            long long x = stoll(a + b.substr(j));
            x *= 1000000001;
            if(x <= n){
                string s = to_string(x);
                string t = s;
                reverse(t.begin(), t.end());
                if(s == t)
                    ++ ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        