結果

問題 No.491 10^9+1と回文
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-03-10 23:12:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 1,632 bytes
コンパイル時間 809 ms
コンパイル使用メモリ 94,492 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 14:23:45
合計ジャッジ時間 8,424 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
6,548 KB
testcase_01 AC 56 ms
6,548 KB
testcase_02 AC 56 ms
6,548 KB
testcase_03 AC 57 ms
6,548 KB
testcase_04 AC 56 ms
6,548 KB
testcase_05 AC 57 ms
6,548 KB
testcase_06 AC 56 ms
6,548 KB
testcase_07 AC 56 ms
6,548 KB
testcase_08 AC 56 ms
6,548 KB
testcase_09 AC 56 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 57 ms
6,548 KB
testcase_12 AC 57 ms
6,548 KB
testcase_13 AC 1 ms
6,548 KB
testcase_14 AC 57 ms
6,548 KB
testcase_15 AC 55 ms
6,548 KB
testcase_16 AC 56 ms
6,548 KB
testcase_17 AC 56 ms
6,548 KB
testcase_18 AC 57 ms
6,548 KB
testcase_19 AC 57 ms
6,548 KB
testcase_20 AC 56 ms
6,548 KB
testcase_21 AC 56 ms
6,548 KB
testcase_22 AC 57 ms
6,548 KB
testcase_23 AC 56 ms
6,548 KB
testcase_24 AC 55 ms
6,548 KB
testcase_25 AC 55 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
testcase_27 AC 56 ms
6,548 KB
testcase_28 AC 56 ms
6,548 KB
testcase_29 AC 55 ms
6,548 KB
testcase_30 AC 55 ms
6,548 KB
testcase_31 AC 2 ms
6,548 KB
testcase_32 AC 56 ms
6,548 KB
testcase_33 AC 56 ms
6,548 KB
testcase_34 AC 55 ms
6,548 KB
testcase_35 AC 56 ms
6,548 KB
testcase_36 AC 1 ms
6,548 KB
testcase_37 AC 55 ms
6,548 KB
testcase_38 AC 55 ms
6,548 KB
testcase_39 AC 53 ms
6,548 KB
testcase_40 AC 1 ms
6,548 KB
testcase_41 AC 56 ms
6,548 KB
testcase_42 AC 55 ms
6,548 KB
testcase_43 AC 57 ms
6,548 KB
testcase_44 AC 54 ms
6,548 KB
testcase_45 AC 55 ms
6,548 KB
testcase_46 AC 56 ms
6,548 KB
testcase_47 AC 55 ms
6,548 KB
testcase_48 AC 56 ms
6,548 KB
testcase_49 AC 1 ms
6,548 KB
testcase_50 AC 55 ms
6,548 KB
testcase_51 AC 55 ms
6,548 KB
testcase_52 AC 56 ms
6,548 KB
testcase_53 AC 1 ms
6,548 KB
testcase_54 AC 54 ms
6,548 KB
testcase_55 AC 55 ms
6,548 KB
testcase_56 AC 54 ms
6,548 KB
testcase_57 AC 55 ms
6,548 KB
testcase_58 AC 57 ms
6,548 KB
testcase_59 AC 55 ms
6,548 KB
testcase_60 AC 56 ms
6,548 KB
testcase_61 AC 56 ms
6,548 KB
testcase_62 AC 54 ms
6,548 KB
testcase_63 AC 55 ms
6,548 KB
testcase_64 AC 56 ms
6,548 KB
testcase_65 AC 55 ms
6,548 KB
testcase_66 AC 54 ms
6,548 KB
testcase_67 AC 55 ms
6,548 KB
testcase_68 AC 57 ms
6,548 KB
testcase_69 AC 2 ms
6,548 KB
testcase_70 AC 54 ms
6,548 KB
testcase_71 AC 54 ms
6,548 KB
testcase_72 AC 55 ms
6,548 KB
testcase_73 AC 56 ms
6,548 KB
testcase_74 AC 59 ms
6,548 KB
testcase_75 AC 60 ms
6,548 KB
testcase_76 AC 55 ms
6,548 KB
testcase_77 AC 55 ms
6,548 KB
testcase_78 AC 56 ms
6,548 KB
testcase_79 AC 56 ms
6,548 KB
testcase_80 AC 2 ms
6,548 KB
testcase_81 AC 56 ms
6,548 KB
testcase_82 AC 56 ms
6,548 KB
testcase_83 AC 55 ms
6,548 KB
testcase_84 AC 56 ms
6,548 KB
testcase_85 AC 56 ms
6,548 KB
testcase_86 AC 55 ms
6,548 KB
testcase_87 AC 56 ms
6,548 KB
testcase_88 AC 1 ms
6,548 KB
testcase_89 AC 55 ms
6,548 KB
testcase_90 AC 55 ms
6,548 KB
testcase_91 AC 55 ms
6,548 KB
testcase_92 AC 53 ms
6,548 KB
testcase_93 AC 56 ms
6,548 KB
testcase_94 AC 56 ms
6,548 KB
testcase_95 AC 55 ms
6,548 KB
testcase_96 AC 54 ms
6,548 KB
testcase_97 AC 54 ms
6,548 KB
testcase_98 AC 54 ms
6,548 KB
testcase_99 AC 55 ms
6,548 KB
testcase_100 AC 55 ms
6,548 KB
testcase_101 AC 56 ms
6,548 KB
testcase_102 AC 57 ms
6,548 KB
testcase_103 AC 56 ms
6,548 KB
testcase_104 AC 59 ms
6,548 KB
testcase_105 AC 56 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

string ntos(long long n){
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}

long long ston(string s){
  long long n;
  sscanf(s.c_str(), "%lld", &n);
  return n;
}

int main() {
  ll n;
  cin>>n;
  ll a = n/1000000000LL;
  if(a==0){
    cout<<0<<endl;
    return 0;
  }
  string s = ntos(a);
  string ss;
  rep(i,0,s.sz/2+s.sz%2){
    ss += s[i];
  }
  per(i,0,s.sz/2){
    ss += s[i];
  }
  ll b = ston(ss);
  ll c = b*1000000000+b;
  int flag = 0;
  if(n>=c){
    flag = 1;
  }
  vector<ll> v;
  rep(i,1,10){
    v.pb(i);
  }
  rep(i,1,10001){
    string s1 = ntos(i);
    string s2 = ntos(i);
    reverse(all(s2));
    string s3 = s1+s2;
    v.pb(ston(s3));
    rep(j,0,10){
      string s4 = ntos(j);
      v.pb(ston(s1+s4+s2));
    }
  }
  ll ans = 0;
  rep(i,0,v.sz){
    if(v[i]<=b)ans++;
  }
  if(flag==0)ans--;
  cout << ans << endl;
  return 0;
}
0