結果
| 問題 |
No.1849 Three Times Value
|
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-09-19 00:35:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 1,830 ms |
| コンパイル使用メモリ | 193,728 KB |
| 最終ジャッジ日時 | 2025-02-16 23:31:03 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 10 |
ソースコード
#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);
if (stoll(a) != (ans+1)) ans += (stoll(a) - 1);
if (stoll(a) <= stoll(b)) ans++;
cout << ans << endl;
}
}
kpinkcat