結果

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

ソースコード

diff #

#include <iostream>
#define int unsigned long long
#define MOD 1000000001
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 * last > n) res--;
	cout << res << endl;
	return 0;
}
0