結果

問題 No.491 10^9+1と回文
ユーザー platypus999platypus999
提出日時 2017-03-10 22:52:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,070 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 102,344 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 08:27:34
合計ジャッジ時間 6,609 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using ll = long long;

int ten(int x)
{
	if (x == 0)return 1;
	return ten(x - 1) * 10;
}

int main(void)
{
	ll n;
	cin >> n;
	int ans = 0;
	for (int d = 1; d <= 9; ++d)
	{
		int half = d / 2 + (d % 2);
		int dow = ten(half - 1);
		int lim = ten(half);
		for (int i = dow; i < lim; ++i)
		{
			if (i % 10 == 0)continue;
			char form[20];
			sprintf(form, "%%0%dd", half);
			char str[20];
			char rev[20];
			sprintf(str, form, i);
			strcpy(rev, str);
			reverse(rev, rev + half);
			if (d % 2)str[d / 2] = '\0';
			strcat(str, rev);
			ll out = atoi(str);
			out *= 1000000001;
			if(out <= n) 
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
0