結果

問題 No.491 10^9+1と回文
ユーザー hkr
提出日時 2017-03-10 23:52:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 55,020 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 09:06:31
合計ジャッジ時間 2,865 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 69
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll num = 1e9 + 1;
    if(n < num) {
        cout << 0 << endl;
        return 0;
    } else {
        ll a = n / num;
        ll ans = 0;
        ll ma = 9;
        int cnt=0;
        int p = 1;
        while(a > 0) {
            cnt++;
            if(cnt%2) p *= 9;
            ma = min<ll>(ma, a%10);
            a /= 10;
            ans += p;
            cnt++;
        }
        ans -= p;
        ans += ma;
        cout << ans << endl;
    }


}
0