結果
問題 |
No.1849 Three Times Value
|
ユーザー |
![]() |
提出日時 | 2023-09-19 00:43:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 784 bytes |
コンパイル時間 | 2,256 ms |
コンパイル使用メモリ | 195,388 KB |
最終ジャッジ日時 | 2025-02-16 23:31:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#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; 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++; else if ((stoll(a) == stoll(b)) && (stoll(a) <= stoll(c)))ans++; cout << ans << endl; } }