結果

問題 No.491 10^9+1と回文
ユーザー MicrobeMicrobe
提出日時 2017-03-11 18:06:28
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 161,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 12:34:16
合計ジャッジ時間 5,378 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 23 WA * 80
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         scanf("%lld", &N);
      |         ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	ll N;
	scanf("%lld", &N);
	N /= (1e9 + 1);
	ll ans = 0;
	FOR(i, 1, 1e5) {
		string num = to_string(i);
		string s = num, t = num;
		reverse(num.begin(), num.end());
		s = s + num;
		t += num.substr(1, num.size() - 1);
		if(stoll(s) <= N || stoll(t) <= N) ++ans;
	}
	printf("%lld\n", ans);
	return 0;
}
0