結果

問題 No.1849 Three Times Value
ユーザー kpinkcatkpinkcat
提出日時 2023-09-19 00:27:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 2,789 ms
コンパイル使用メモリ 202,208 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-19 00:27:54
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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 (a == min({a, b, c})) ans++;
        cout << ans << endl; 
    }
}
0