結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
ninoinui
|
| 提出日時 | 2020-08-22 19:04:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 499 bytes |
| コンパイル時間 | 2,271 ms |
| コンパイル使用メモリ | 194,576 KB |
| 最終ジャッジ日時 | 2025-01-13 11:37:06 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int ans = 0;
function<void(long)> dfs = [&](long n) -> void {
if (n > N) return;
if (n > 9) ans++;
string s = to_string(n);
for (int next = 0; next <= 9; next++) {
for (int i = 0; i < s.size(); i++) {
int tmp = s.at(i) - '0';
if ((tmp + next) % 3) goto NG;
}
dfs(n * 10 + next);
NG:;
}
};
for (int i = 1; i <= 9; i++) dfs(i);
cout << ans << "\n";
}
ninoinui