結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
![]() |
提出日時 | 2020-08-22 18:49:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 3,840 ms |
コンパイル使用メモリ | 190,548 KB |
最終ジャッジ日時 | 2025-01-13 11:36:06 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() using namespace std; using P = pair<int, int>; typedef long long ll; ll num[12] = {30, 33, 36, 39, 60, 63, 66, 69, 90, 93, 96, 99}; const ll three[4] = {0,3,6,9}; int ans; int n; void dfs(ll num) { if(num > n)return; ans++; rep(i, 4) { if(num * 10 + three[i] > n)return; dfs(10 * num + three[i]); } } int main() { cin >> n; if(n <= 99){ cout << n / 3 - 3 << endl; return 0; } ans = 30; rep(i, 12) { rep(j, 4) { dfs(num[i] * 10 + three[j]); } } cout << ans << endl; }