結果

問題 No.491 10^9+1と回文
ユーザー pazzle1230pazzle1230
提出日時 2017-03-10 23:17:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,305 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 92,960 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 14:08:34
合計ジャッジ時間 4,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,384 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 WA -
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 1 ms
4,376 KB
testcase_53 WA -
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 AC 2 ms
4,376 KB
testcase_65 AC 2 ms
4,380 KB
testcase_66 AC 2 ms
4,376 KB
testcase_67 WA -
testcase_68 AC 1 ms
4,376 KB
testcase_69 WA -
testcase_70 AC 1 ms
4,380 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 AC 1 ms
4,380 KB
testcase_75 AC 2 ms
4,380 KB
testcase_76 AC 2 ms
4,380 KB
testcase_77 AC 2 ms
4,376 KB
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 AC 2 ms
4,380 KB
testcase_82 AC 1 ms
4,376 KB
testcase_83 WA -
testcase_84 AC 1 ms
4,380 KB
testcase_85 WA -
testcase_86 AC 1 ms
4,380 KB
testcase_87 AC 1 ms
4,380 KB
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 2 ms
4,376 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 2 ms
4,376 KB
testcase_96 AC 2 ms
4,376 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 <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(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(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

class RMQ{
	vector<int> dat;
	int n;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int k){
		if(a <= l && r <= b) return dat[k];
		if(b <= l || r <= a) return INF;

		return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
	}

	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

ll con = 1000000001;

int keta(ll n){
	int res = 0;
	while(n > 0){
		n /= 10;
		res++;
	}
	return res;
}

ll dbl(ll n, int f){
	ll res = n * pow(10, keta(n)-f);
	int p = keta(n)-1-f;

	if(f)
		n /= 10;
	while(n > 0){
		res += (n%10)*pow(10, p);
		n/=10;
		p--;
	}
	return res;
}

int main(void){
	ll N;
	ll tmp_N;
	ll res = 0;
	cin >> N;
	tmp_N = N;
	N /= con;
	int p = 0;
	while(N/10 > 0){
		res += pow(9, p/2+1);
		N /= 10;
		p++;
	}
	tmp_N /= con;
	int flag = keta(tmp_N)%2;
	int dig = keta(tmp_N);
	for(ll i = pow(10, dig/2+(dig%2)-1);dbl(i, dig%2) <= tmp_N;i++){
		res++;
	}
	cout << res << endl;
}
0