結果

問題 No.491 10^9+1と回文
ユーザー Catty Zhu
提出日時 2025-05-18 21:12:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 191,304 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-05-18 21:12:58
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 103
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         freopen("palindrome.in","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:6:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         freopen("palindrome.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	freopen("palindrome.in","r",stdin);
	freopen("palindrome.out","w",stdout);
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			int t=9-i;
			int x=0;
			for(int k=1;k<=i;k++){
				x=x*10+j;
			}
			for(int k=1;k<=t;k++){
				x*=10;
			}
			for(int k=1;k<=i;k++){
				x=x*10+j;
			}
			if(x<=n){
				cnt++;
			}else{
				break;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}
0