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