結果
| 問題 |
No.2450 99-like Number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-26 03:11:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 807 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 74,396 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-07-26 03:11:16 |
| 合計ジャッジ時間 | 1,842 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
// Hàm cộng 1 vào số nguyên lớn biểu diễn dưới dạng chuỗi
string add_one(const string& num) {
string res = num;
int n = res.size();
int carry = 1;
for (int i = n - 1; i >= 0; --i) {
int sum = (res[i] - '0') + carry;
res[i] = (sum % 10) + '0';
carry = sum / 10;
if (!carry) break;
}
if (carry) res = '1' + res;
return res;
}
int main() {
string N;
cin >> N;
string N_plus_1 = add_one(N);
// Kiểm tra N+1 có dạng 1 và toàn 0 không?
if (N_plus_1[0] == '1' && count(N_plus_1.begin() + 1, N_plus_1.end(), '0') == N_plus_1.size() - 1)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}