結果

問題 No.491 10^9+1と回文
ユーザー xxxasdfghjkxxxasdfghjk
提出日時 2018-08-21 00:21:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,478 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 25,412 KB
最終ジャッジ日時 2023-08-18 15:13:12
合計ジャッジ時間 24,228 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
23,524 KB
testcase_01 AC 170 ms
24,748 KB
testcase_02 AC 170 ms
23,224 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 173 ms
24,112 KB
testcase_09 AC 174 ms
24,304 KB
testcase_10 AC 173 ms
24,252 KB
testcase_11 AC 175 ms
24,124 KB
testcase_12 AC 175 ms
23,912 KB
testcase_13 AC 172 ms
23,520 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 173 ms
23,520 KB
testcase_17 AC 173 ms
23,704 KB
testcase_18 AC 172 ms
23,852 KB
testcase_19 AC 173 ms
23,612 KB
testcase_20 AC 172 ms
23,284 KB
testcase_21 AC 173 ms
24,152 KB
testcase_22 AC 176 ms
24,020 KB
testcase_23 WA -
testcase_24 AC 171 ms
23,516 KB
testcase_25 AC 173 ms
23,488 KB
testcase_26 AC 175 ms
23,528 KB
testcase_27 AC 175 ms
23,704 KB
testcase_28 AC 176 ms
23,704 KB
testcase_29 AC 171 ms
23,792 KB
testcase_30 WA -
testcase_31 AC 173 ms
23,120 KB
testcase_32 WA -
testcase_33 AC 172 ms
24,848 KB
testcase_34 AC 170 ms
24,144 KB
testcase_35 WA -
testcase_36 AC 173 ms
23,552 KB
testcase_37 AC 171 ms
24,304 KB
testcase_38 AC 172 ms
24,820 KB
testcase_39 AC 173 ms
24,244 KB
testcase_40 AC 173 ms
23,980 KB
testcase_41 AC 172 ms
25,212 KB
testcase_42 AC 174 ms
23,848 KB
testcase_43 AC 172 ms
24,252 KB
testcase_44 AC 171 ms
24,144 KB
testcase_45 AC 174 ms
23,072 KB
testcase_46 AC 172 ms
24,440 KB
testcase_47 AC 172 ms
24,488 KB
testcase_48 AC 171 ms
24,696 KB
testcase_49 AC 173 ms
23,652 KB
testcase_50 AC 174 ms
24,840 KB
testcase_51 WA -
testcase_52 AC 174 ms
23,684 KB
testcase_53 AC 172 ms
23,604 KB
testcase_54 AC 173 ms
23,836 KB
testcase_55 AC 175 ms
23,784 KB
testcase_56 AC 174 ms
23,320 KB
testcase_57 AC 175 ms
23,860 KB
testcase_58 WA -
testcase_59 AC 172 ms
23,892 KB
testcase_60 AC 173 ms
24,192 KB
testcase_61 AC 172 ms
23,536 KB
testcase_62 AC 173 ms
24,412 KB
testcase_63 WA -
testcase_64 AC 174 ms
23,868 KB
testcase_65 AC 175 ms
24,488 KB
testcase_66 AC 172 ms
23,464 KB
testcase_67 WA -
testcase_68 AC 176 ms
24,020 KB
testcase_69 AC 171 ms
23,800 KB
testcase_70 AC 171 ms
24,080 KB
testcase_71 WA -
testcase_72 AC 174 ms
23,656 KB
testcase_73 AC 172 ms
24,516 KB
testcase_74 AC 171 ms
23,224 KB
testcase_75 AC 173 ms
23,964 KB
testcase_76 AC 171 ms
24,448 KB
testcase_77 AC 173 ms
23,512 KB
testcase_78 AC 171 ms
23,072 KB
testcase_79 AC 174 ms
24,076 KB
testcase_80 AC 173 ms
23,708 KB
testcase_81 AC 171 ms
24,652 KB
testcase_82 AC 174 ms
23,860 KB
testcase_83 AC 172 ms
23,704 KB
testcase_84 AC 173 ms
24,396 KB
testcase_85 AC 173 ms
24,552 KB
testcase_86 AC 171 ms
23,944 KB
testcase_87 AC 169 ms
24,376 KB
testcase_88 AC 172 ms
24,496 KB
testcase_89 AC 176 ms
23,608 KB
testcase_90 AC 175 ms
23,808 KB
testcase_91 AC 173 ms
23,752 KB
testcase_92 AC 173 ms
23,768 KB
testcase_93 AC 170 ms
23,136 KB
testcase_94 WA -
testcase_95 AC 175 ms
24,548 KB
testcase_96 AC 173 ms
23,320 KB
testcase_97 WA -
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 WA -
testcase_104 WA -
testcase_105 WA -
権限があれば一括ダウンロードができます

ソースコード

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 / (10E8+1);
  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<=11;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);
      }
    }
    kaibun[i].push_back(0);
  }
  sort(kaib.begin(),kaib.end());
  kaib.erase(kaib.begin());
  kaib.erase(kaib.begin());
  cout << abs(kaib.begin()-upper_bound(kaib.begin(),kaib.end(),sin)) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}
0