結果

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

ソースコード

diff #

#include <iostream>
#define int long long
#define MOD 1000000000
using namespace std;

signed main(){
	int n,cnt,res = 0,last = 1;
	cin >> n;
	if(n <= MOD){
		cout << 0 << endl;
		return 0;
	} 
	cnt = n / MOD;
	while(last <= cnt) last = last * 10 + 1;
	last /= 10;
	cnt = (int)(cnt / last) * last;
	last = cnt;
	res += cnt % 10;
	cnt /= 10;
	while(cnt){
		cnt /= 10;
		res += 9;
	}
	if((MOD + 1) * last > n) res--;
	cout << res << endl;
	return 0;
}
0