結果

問題 No.491 10^9+1と回文
ユーザー vjudge1
提出日時 2025-05-16 16:21:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,823 bytes
コンパイル時間 4,355 ms
コンパイル使用メモリ 289,472 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-16 16:21:50
合計ジャッジ時間 8,229 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 93 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
bool hw(ll x){
	string s=to_string(x);
	string t=s;
	reverse(t.begin(),t.end());
	return s==t;
}
int main(){
//	freopen("palindrome.in","r",stdin);
//	freopen("palindrome.out","w",stdout);
	cin>>n;
	n/=1000000000;
//	cout<<n<<endl;
	vector<tuple<ll,ll,ll>>vec(100);
	vec[0]={1998,1,1000000},vec[1]={1000,1000001,2000000},vec[2]={1000,2000001,3000000},vec[3]={1000,3000001,4000000},vec[4]={1000,4000001,5000000},vec[5]={1000,5000001,6000000},vec[6]={1000,6000001,7000000},vec[7]={1000,7000001,8000000},vec[8]={1000,8000001,9000000},vec[9]={1000,9000001,10000000},vec[10]={100,10000001,11000000},vec[11]={100,11000001,12000000},vec[12]={100,12000001,13000000},vec[13]={100,13000001,14000000},vec[14]={100,14000001,15000000},vec[15]={100,15000001,16000000},vec[16]={100,16000001,17000000},vec[17]={100,17000001,18000000},vec[18]={100,18000001,19000000},vec[19]={100,19000001,20000000},vec[20]={100,20000001,21000000},vec[21]={100,21000001,22000000},vec[22]={100,22000001,23000000},vec[23]={100,23000001,24000000},vec[24]={100,24000001,25000000},vec[25]={100,25000001,26000000},vec[26]={100,26000001,27000000},vec[27]={100,27000001,28000000},vec[28]={100,28000001,29000000},vec[29]={100,29000001,30000000},vec[30]={100,30000001,31000000},vec[31]={100,31000001,32000000},vec[32]={100,32000001,33000000},vec[33]={100,33000001,34000000},vec[34]={100,34000001,35000000},vec[35]={100,35000001,36000000},vec[36]={100,36000001,37000000},vec[37]={100,37000001,38000000},vec[38]={100,38000001,39000000},vec[39]={100,39000001,40000000},vec[40]={100,40000001,41000000},vec[41]={100,41000001,42000000},vec[42]={100,42000001,43000000},vec[43]={100,43000001,44000000},vec[44]={100,44000001,45000000},vec[45]={100,45000001,46000000},vec[46]={100,46000001,47000000},vec[47]={100,47000001,48000000},vec[48]={100,48000001,49000000},vec[49]={100,49000001,50000000},vec[50]={100,50000001,51000000},vec[51]={100,51000001,52000000},vec[52]={100,52000001,53000000},vec[53]={100,53000001,54000000},vec[54]={100,54000001,55000000},vec[55]={100,55000001,56000000},vec[56]={100,56000001,57000000},vec[57]={100,57000001,58000000},vec[58]={100,58000001,59000000},vec[59]={100,59000001,60000000},vec[60]={100,60000001,61000000},vec[61]={100,61000001,62000000},vec[62]={100,62000001,63000000},vec[63]={100,63000001,64000000},vec[64]={100,64000001,65000000},vec[65]={100,65000001,66000000},vec[66]={100,66000001,67000000},vec[67]={100,67000001,68000000},vec[68]={100,68000001,69000000},vec[69]={100,69000001,70000000},vec[70]={100,70000001,71000000},vec[71]={100,71000001,72000000},vec[72]={100,72000001,73000000},vec[73]={100,73000001,74000000},vec[74]={100,74000001,75000000},vec[75]={100,75000001,76000000},vec[76]={100,76000001,77000000},vec[77]={100,77000001,78000000},vec[78]={100,78000001,79000000},vec[79]={100,79000001,80000000},vec[80]={100,80000001,81000000},vec[81]={100,81000001,82000000},vec[82]={100,82000001,83000000},vec[83]={100,83000001,84000000},vec[84]={100,84000001,85000000},vec[85]={100,85000001,86000000},vec[86]={100,86000001,87000000},vec[87]={100,87000001,88000000},vec[88]={100,88000001,89000000},vec[89]={100,89000001,90000000},vec[90]={100,90000001,91000000},vec[91]={100,91000001,92000000},vec[92]={100,92000001,93000000},vec[93]={100,93000001,94000000},vec[94]={100,94000001,95000000},vec[95]={100,95000001,96000000},vec[96]={100,96000001,97000000},vec[97]={100,97000001,98000000},vec[98]={100,98000001,99000000},vec[99]={100,99000001,100000000};
	ll st=0,ed=n/1000000,ans=0;
	for(ll i=st;i<ed;i++){
//		cout<<i<<" "<<st<<" "<<ed<<" "<<ans<<endl;
		ans+=get<0>(vec[i]);
	}
//	cout<<endl;
//	cout<<ed*1000000<<endl;
	for(ll i=ed*1000000+1;i<=n;i++){
		if(hw(i)){
//			cout<<i<<" ";
			ans++;	
		}
	}
//	cout<<endl;
	cout<<ans;
	
}
/*
11451419198100000
*/
0