結果

問題 No.491 10^9+1と回文
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-11 00:02:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 2,383 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 166,408 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-24 13:12:07
合計ジャッジ時間 5,192 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
ll N;
//-----------------------------------------------------------------
int main() {
	cin >> N;

	int ans = 0;
	rep(i, 1, 101010) {
		string s = to_string(i);
		int n = s.length();

		/*bool ng = false;
		rep(j, 0, n) if (s[j] == '0') ng = true;
		if (ng) continue;*/

		// 奇数
		ll x = 0;
		rep(i, 0, n - 1) x = x * 10 + s[i] - '0';
		x = x * 10 + s[n - 1] - '0';
		rep(i, 0, n - 1) x = x * 10 + s[n - 2 - i] - '0';
		//cout << x << endl;
		int nx = (n - 1) * 2 + 1;
		ll a = x;
		rep(i, 0, 9) a *= 10;
		a += x;

		if (a < 0) continue;

		if (a <= N) {
			//printf("%lld\n", a);
			ans++;
		}

		// 偶数
		ll xx = 0;
		rep(i, 0, n) xx = xx * 10 + s[i] - '0';
		rep(i, 0, n) xx = xx * 10 + s[n - 1 - i] - '0';
		//cout << xx << endl;
		int nxx = n * 2;
		ll b = xx;
		rep(i, 0, 9) b *= 10;
		b += xx;

		if (b < 0) continue;
		
		if (b <= N) {
			//printf("%lld\n", b);
			ans++;
		}
	}

	cout << ans << endl;
	return 0;


	/*

	ll mo = 1000000001;

	int dig = 0;
	ll t = N;
	while (0 < t) dig++, t /= 10;

	ll ans = 0;
	rrep(i, 8, 1) {
		ll cc = 0;
		int d = i + 2 * (9 - i);
		if (d < dig) {
			// 全部OK
			int j = 9 - i;

			if (j == 1) {
				cc = 9;
			}
			else if (j % 2 == 0) {
				int k = j / 2 - 1;
				ll c = 9;
				rep(kk, 0, k) c *= 9;
				cc += c;
			}
			else {
				int k = j / 2;
				ll c = 9;
				rep(kk, 0, k) c *= 9;
				cc += c;
			}
		}
		else if (d == dig) {
			// 一部OK
			int j = 9 - i;

			string n = to_string(N);
			int ma = 0;
			rep(i, 0, j) ma = ma * 10 + n[i] - '0';

			int mi = 0;
			rep(i, 0, j) mi = mi * 10 + 1;

			if (mi < ma) {
				//if(j % 2 == 0)

				rep(x, mi, ma) {
					string s = to_string(x);
					bool ok = true;
					rep(i, 0, s.length() / 2 + 1) {
						int j = s.length() - 1 - i;
						if (s[i] != s[j]) ok = false;
						if (s[i] == '0') ok = false;
					}
					if (ok) cc++;
				}
			}

			ll th = ma;
			rep(i, 0, d - j * 2) th *= 10;
			int y = ma;
			while (0 < y) {
				th = th * 10 + y % 10;
				y /= 10;
			}

			if (th <= N) cc++;

			//cout << th << endl;

			//printf("[%d %d]\n", mi, ma);
		}

		ans += cc;
		//if(0 < cc) printf("%d -> %lld\n", d, cc);
	}
	cout << ans << endl;*/

	ll mo = 1000000001;
	rep(i, 1, 1000) {
		printf("%lld\n", mo * i);
	}
}
0