結果

問題 No.1849 Three Times Value
ユーザー kpinkcat
提出日時 2023-09-19 00:32:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 196,120 KB
最終ジャッジ日時 2025-02-16 23:30:54
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;

int main()
{
    string n;
    ll ans = 0;
    cin >> n;
    if (n.size() < 3) cout << 0 << "\n";
    else if (n.size() >= 3 && (n.size()%3)){
        ans = pow(10, n.size()/3) - 1;
        cout << ans << endl;
    } else {
        string a, b, c;
        ans = pow(10, n.size()/3 - 1) - 1;
        a = n.substr(0, n.size()/3);
        b = n.substr(n.size()/3, n.size()/3);
        c = n.substr(n.size()*2/3, n.size()/3);
        ans += (stoll(a) - 1);
        if (stoll(a) <= stoll(b)) ans++;
        cout << ans << endl; 
    }
}
0