結果
問題 | No.1849 Three Times Value |
ユーザー |
![]() |
提出日時 | 2023-09-19 00:27:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 757 bytes |
コンパイル時間 | 2,230 ms |
コンパイル使用メモリ | 196,360 KB |
最終ジャッジ日時 | 2025-02-16 23:30:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 13 |
ソースコード
#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;}}