結果

問題 No.1185 完全な3の倍数
ユーザー glretoglreto
提出日時 2021-03-09 17:06:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,326 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 95,908 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 20:17:19
合計ジャッジ時間 2,374 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,816 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,948 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 3 ms
6,948 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<deque>
#include<math.h>
#include<set>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<stack>
#include<map>
using namespace std;
#define rep(i,n) for(ll i = 0;i<n;i++)
#define req(i,n) for(ll i = 1;i<=n;i++)
#define rrep(i,n) for(int i = n-1;i>=0;i--)
#define ALL(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef unsigned long long ll;
typedef long double ld;
int dfs(int n, int now,int cnt) {
    int res = 0;
    if (cnt == 9) {
        if (now > 10&&now <= n) {
            return 1;
        }
        else return 0;
    }res += dfs(n, now * 10, cnt + 1);
    res += dfs(n, now * 10 + 3, cnt + 1);
    res += dfs(n, now * 10 + 6, cnt + 1);
    res += dfs(n, now * 10 + 9, cnt + 1);
    return res;
}
int main() {
    int n,ans = 0; cin >> n;
    if (n < 100) {
        for (int i = 10; i <= n; i++) {
            if (i % 3 == 0) ans++;
        }cout << ans << endl;
    }
    else {
        for (int i = 10; i <100; i++) {
            if (i % 3 == 0) ans++;
        }
        cout << ans + dfs(n, 0, 0)-12 << endl;
    }
}
0