結果

問題 No.491 10^9+1と回文
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-03-10 23:10:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 872 ms / 1,000 ms
コード長 1,633 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 92,684 KB
実行使用メモリ 21,632 KB
最終ジャッジ日時 2023-09-06 14:11:40
合計ジャッジ時間 80,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 775 ms
20,952 KB
testcase_01 AC 801 ms
21,316 KB
testcase_02 AC 862 ms
20,464 KB
testcase_03 AC 842 ms
19,864 KB
testcase_04 AC 847 ms
21,524 KB
testcase_05 AC 746 ms
21,016 KB
testcase_06 AC 745 ms
20,904 KB
testcase_07 AC 749 ms
20,080 KB
testcase_08 AC 755 ms
20,660 KB
testcase_09 AC 818 ms
19,648 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 787 ms
20,632 KB
testcase_12 AC 743 ms
20,560 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 782 ms
20,336 KB
testcase_15 AC 759 ms
20,912 KB
testcase_16 AC 747 ms
21,316 KB
testcase_17 AC 747 ms
20,624 KB
testcase_18 AC 754 ms
20,716 KB
testcase_19 AC 777 ms
19,824 KB
testcase_20 AC 832 ms
20,624 KB
testcase_21 AC 818 ms
19,664 KB
testcase_22 AC 768 ms
20,100 KB
testcase_23 AC 743 ms
19,848 KB
testcase_24 AC 756 ms
19,696 KB
testcase_25 AC 748 ms
20,180 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 742 ms
20,408 KB
testcase_28 AC 759 ms
20,780 KB
testcase_29 AC 769 ms
20,008 KB
testcase_30 AC 836 ms
20,128 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 777 ms
20,240 KB
testcase_33 AC 745 ms
20,440 KB
testcase_34 AC 750 ms
20,456 KB
testcase_35 AC 745 ms
21,408 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 750 ms
20,504 KB
testcase_38 AC 811 ms
20,252 KB
testcase_39 AC 788 ms
20,240 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 796 ms
19,912 KB
testcase_42 AC 750 ms
20,128 KB
testcase_43 AC 747 ms
19,712 KB
testcase_44 AC 760 ms
20,348 KB
testcase_45 AC 741 ms
19,620 KB
testcase_46 AC 757 ms
20,072 KB
testcase_47 AC 770 ms
19,860 KB
testcase_48 AC 836 ms
20,308 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 846 ms
21,040 KB
testcase_51 AC 789 ms
20,080 KB
testcase_52 AC 789 ms
20,384 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 819 ms
19,888 KB
testcase_55 AC 779 ms
20,260 KB
testcase_56 AC 743 ms
20,824 KB
testcase_57 AC 745 ms
20,148 KB
testcase_58 AC 739 ms
20,220 KB
testcase_59 AC 756 ms
21,020 KB
testcase_60 AC 758 ms
20,828 KB
testcase_61 AC 772 ms
20,240 KB
testcase_62 AC 833 ms
21,632 KB
testcase_63 AC 783 ms
20,112 KB
testcase_64 AC 752 ms
20,672 KB
testcase_65 AC 768 ms
20,748 KB
testcase_66 AC 755 ms
20,596 KB
testcase_67 AC 762 ms
19,916 KB
testcase_68 AC 774 ms
20,820 KB
testcase_69 AC 2 ms
4,380 KB
testcase_70 AC 752 ms
20,360 KB
testcase_71 AC 813 ms
19,828 KB
testcase_72 AC 835 ms
20,696 KB
testcase_73 AC 838 ms
21,168 KB
testcase_74 AC 787 ms
20,080 KB
testcase_75 AC 773 ms
19,884 KB
testcase_76 AC 767 ms
19,736 KB
testcase_77 AC 756 ms
19,716 KB
testcase_78 AC 750 ms
21,272 KB
testcase_79 AC 749 ms
20,700 KB
testcase_80 AC 1 ms
4,376 KB
testcase_81 AC 752 ms
20,008 KB
testcase_82 AC 845 ms
20,584 KB
testcase_83 AC 819 ms
20,672 KB
testcase_84 AC 831 ms
20,668 KB
testcase_85 AC 758 ms
20,248 KB
testcase_86 AC 745 ms
20,584 KB
testcase_87 AC 746 ms
20,056 KB
testcase_88 AC 1 ms
4,376 KB
testcase_89 AC 750 ms
19,624 KB
testcase_90 AC 748 ms
20,236 KB
testcase_91 AC 750 ms
20,988 KB
testcase_92 AC 752 ms
19,920 KB
testcase_93 AC 838 ms
20,356 KB
testcase_94 AC 872 ms
21,492 KB
testcase_95 AC 838 ms
20,572 KB
testcase_96 AC 761 ms
20,816 KB
testcase_97 AC 749 ms
20,548 KB
testcase_98 AC 753 ms
20,208 KB
testcase_99 AC 804 ms
21,552 KB
testcase_100 AC 766 ms
21,088 KB
testcase_101 AC 752 ms
19,840 KB
testcase_102 AC 775 ms
21,468 KB
testcase_103 AC 838 ms
19,784 KB
testcase_104 AC 835 ms
19,916 KB
testcase_105 AC 782 ms
21,104 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,100000){
    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