結果

問題 No.1185 完全な3の倍数
ユーザー hiragnhiragn
提出日時 2020-08-24 03:29:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 204,900 KB
実行使用メモリ 15,744 KB
最終ジャッジ日時 2024-05-03 10:41:35
合計ジャッジ時間 4,702 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
14,080 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 66 ms
13,440 KB
testcase_04 AC 79 ms
14,976 KB
testcase_05 AC 73 ms
14,208 KB
testcase_06 AC 68 ms
13,568 KB
testcase_07 AC 66 ms
13,440 KB
testcase_08 AC 84 ms
15,744 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 18 ms
6,400 KB
testcase_20 AC 60 ms
12,672 KB
testcase_21 AC 38 ms
9,600 KB
testcase_22 AC 21 ms
7,424 KB
testcase_23 AC 19 ms
6,528 KB
testcase_24 AC 61 ms
12,672 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 39 ms
9,600 KB
testcase_27 AC 19 ms
6,528 KB
testcase_28 AC 40 ms
9,984 KB
testcase_29 AC 32 ms
8,832 KB
testcase_30 AC 39 ms
9,472 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 73 ms
14,208 KB
testcase_33 AC 13 ms
5,632 KB
testcase_34 AC 61 ms
12,800 KB
testcase_35 AC 78 ms
14,976 KB
testcase_36 AC 60 ms
12,544 KB
testcase_37 AC 61 ms
12,672 KB
testcase_38 AC 37 ms
9,472 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0