結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
![]() |
提出日時 | 2020-08-24 03:29:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 2,501 ms |
コンパイル使用メモリ | 196,188 KB |
最終ジャッジ日時 | 2025-01-13 13:11:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; lint n; set<lint> st; void dfs(lint cur) { if (cur > n) return; if (cur > 100) st.insert(cur); dfs(cur * 10); dfs(cur * 10 + 3); dfs(cur * 10 + 6); dfs(cur * 10 + 9); } int main() { cin >> n; // 2桁の場合 for (lint i = 12; i < 100 and i <= n; i += 3) { st.insert(i); } // 3桁以上の場合 dfs(3); dfs(6); dfs(9); cout << st.size() << endl; return 0; }