結果

問題 No.491 10^9+1と回文
ユーザー xxxasdfghjkxxxasdfghjk
提出日時 2018-08-21 01:17:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 1,564 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 83,012 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-08-18 19:00:29
合計ジャッジ時間 8,726 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
7,708 KB
testcase_01 AC 43 ms
7,772 KB
testcase_02 AC 41 ms
7,624 KB
testcase_03 AC 42 ms
7,708 KB
testcase_04 AC 40 ms
7,652 KB
testcase_05 AC 40 ms
7,764 KB
testcase_06 AC 42 ms
7,768 KB
testcase_07 AC 42 ms
7,768 KB
testcase_08 AC 41 ms
7,604 KB
testcase_09 AC 40 ms
7,716 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 40 ms
7,908 KB
testcase_12 AC 40 ms
7,812 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 41 ms
7,660 KB
testcase_15 AC 41 ms
7,604 KB
testcase_16 AC 41 ms
7,676 KB
testcase_17 AC 40 ms
7,620 KB
testcase_18 AC 43 ms
7,560 KB
testcase_19 AC 40 ms
7,656 KB
testcase_20 AC 40 ms
7,600 KB
testcase_21 AC 40 ms
7,704 KB
testcase_22 AC 42 ms
7,560 KB
testcase_23 AC 41 ms
7,800 KB
testcase_24 AC 41 ms
7,816 KB
testcase_25 AC 40 ms
7,700 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 41 ms
7,808 KB
testcase_28 AC 40 ms
7,632 KB
testcase_29 AC 41 ms
7,652 KB
testcase_30 AC 39 ms
7,560 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 40 ms
7,860 KB
testcase_33 AC 41 ms
7,800 KB
testcase_34 AC 41 ms
7,556 KB
testcase_35 AC 42 ms
7,744 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 41 ms
7,700 KB
testcase_38 AC 41 ms
7,560 KB
testcase_39 AC 41 ms
7,560 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 41 ms
7,556 KB
testcase_42 AC 42 ms
7,720 KB
testcase_43 AC 40 ms
7,692 KB
testcase_44 AC 40 ms
7,796 KB
testcase_45 AC 40 ms
7,684 KB
testcase_46 AC 42 ms
7,768 KB
testcase_47 AC 42 ms
7,560 KB
testcase_48 AC 40 ms
7,892 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 42 ms
7,556 KB
testcase_51 AC 42 ms
7,628 KB
testcase_52 AC 41 ms
7,556 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 40 ms
7,708 KB
testcase_55 AC 40 ms
7,560 KB
testcase_56 AC 41 ms
7,892 KB
testcase_57 AC 40 ms
7,564 KB
testcase_58 AC 40 ms
7,704 KB
testcase_59 AC 41 ms
7,600 KB
testcase_60 AC 43 ms
7,852 KB
testcase_61 AC 41 ms
7,620 KB
testcase_62 AC 41 ms
7,676 KB
testcase_63 AC 40 ms
7,560 KB
testcase_64 AC 43 ms
7,684 KB
testcase_65 AC 42 ms
7,680 KB
testcase_66 AC 43 ms
7,812 KB
testcase_67 AC 43 ms
7,652 KB
testcase_68 AC 40 ms
7,744 KB
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 43 ms
7,556 KB
testcase_71 AC 41 ms
7,768 KB
testcase_72 AC 42 ms
7,700 KB
testcase_73 AC 42 ms
7,868 KB
testcase_74 AC 42 ms
7,636 KB
testcase_75 AC 41 ms
7,744 KB
testcase_76 AC 41 ms
7,864 KB
testcase_77 AC 40 ms
7,604 KB
testcase_78 AC 40 ms
7,744 KB
testcase_79 AC 40 ms
7,660 KB
testcase_80 AC 1 ms
4,376 KB
testcase_81 AC 41 ms
7,564 KB
testcase_82 AC 43 ms
7,796 KB
testcase_83 AC 43 ms
7,744 KB
testcase_84 AC 44 ms
7,656 KB
testcase_85 AC 41 ms
7,556 KB
testcase_86 AC 44 ms
7,716 KB
testcase_87 AC 44 ms
7,656 KB
testcase_88 AC 2 ms
4,376 KB
testcase_89 AC 47 ms
7,556 KB
testcase_90 AC 42 ms
7,656 KB
testcase_91 AC 43 ms
7,916 KB
testcase_92 AC 41 ms
7,772 KB
testcase_93 AC 41 ms
7,624 KB
testcase_94 AC 40 ms
7,652 KB
testcase_95 AC 40 ms
7,560 KB
testcase_96 AC 42 ms
7,892 KB
testcase_97 AC 40 ms
7,600 KB
testcase_98 AC 42 ms
7,744 KB
testcase_99 AC 44 ms
7,948 KB
testcase_100 AC 42 ms
7,652 KB
testcase_101 AC 41 ms
7,688 KB
testcase_102 AC 41 ms
7,816 KB
testcase_103 AC 40 ms
7,604 KB
testcase_104 AC 43 ms
7,660 KB
testcase_105 AC 41 ms
7,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,sin;
  cin >> N;
  sin = N / (1000000001);
  if(sin == 0){
    cout << 0 << endl;
    return 0;
  }
  vector<vector<ll> > kaibun(12,vector<ll>(0));
  vector<ll> kaib(0);
  for(int i=0;i<=9;i++){
    kaibun[1].push_back(i);
    kaib.push_back(i);
  }
  for(int i=0;i<=9;i++){
    kaibun[2].push_back(i*11);
    kaib.push_back(i*11);
  }
  for(int i=3;i<=10;i++){
    for(int j=0;j<kaibun[i-2].size();j++){
      for(int k=1;k<=9;k++){
        kaibun[i].push_back(k*pow(10,i-1)+10*kaibun[i-2][j]+k);
        kaib.push_back(k*pow(10,i-1)+10*kaibun[i-2][j]+k);
        
      }
    }
    REP(k,kaibun[i-2].size()){
      kaibun[i].push_back(10*kaibun[i-2][k]);
    }
  }
  sort(kaib.begin(),kaib.end());
  kaib.erase(unique(kaib.begin(),kaib.end()),kaib.end());
  kaib.erase(kaib.begin());
  cout << upper_bound(kaib.begin(),kaib.end(),sin) - kaib.begin() << endl;
  return 0;
}

0