結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
|
提出日時 | 2020-08-22 15:09:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 2,762 ms |
コンパイル使用メモリ | 197,104 KB |
最終ジャッジ日時 | 2025-01-13 09:11:42 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) set<int> st; void dfs(int u, int p) { if(u == 9) { if(p >= 100) st.insert(p); return; } dfs(u+1,p); dfs(u+1,p+3*pow(10,u)); dfs(u+1,p+6*pow(10,u)); dfs(u+1,p+9*pow(10,u)); } int main(){ int n; cin >> n; for(int i = 10; i <= 99; i++) { if(i % 3 == 0) st.insert(i); } dfs(0,0); int ans = 0; for(auto x : st) { if(x <= n && x >= 10) ans++; } cout << ans << endl; return 0; }