結果

問題 No.1185 完全な3の倍数
ユーザー kenskens
提出日時 2020-08-22 15:09:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 203,508 KB
実行使用メモリ 16,352 KB
最終ジャッジ日時 2023-08-16 00:17:05
合計ジャッジ時間 7,426 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
16,084 KB
testcase_01 AC 86 ms
16,112 KB
testcase_02 AC 86 ms
15,996 KB
testcase_03 AC 87 ms
16,216 KB
testcase_04 AC 89 ms
16,088 KB
testcase_05 AC 88 ms
16,044 KB
testcase_06 AC 87 ms
16,080 KB
testcase_07 AC 88 ms
16,148 KB
testcase_08 AC 88 ms
16,028 KB
testcase_09 AC 86 ms
16,016 KB
testcase_10 AC 93 ms
16,028 KB
testcase_11 AC 90 ms
16,080 KB
testcase_12 AC 84 ms
16,024 KB
testcase_13 AC 85 ms
16,104 KB
testcase_14 AC 88 ms
15,980 KB
testcase_15 AC 86 ms
16,148 KB
testcase_16 AC 88 ms
16,172 KB
testcase_17 AC 90 ms
16,004 KB
testcase_18 AC 90 ms
16,028 KB
testcase_19 AC 85 ms
16,012 KB
testcase_20 AC 87 ms
15,996 KB
testcase_21 AC 92 ms
16,076 KB
testcase_22 AC 92 ms
15,984 KB
testcase_23 AC 96 ms
16,020 KB
testcase_24 AC 88 ms
16,056 KB
testcase_25 AC 118 ms
15,996 KB
testcase_26 AC 111 ms
16,216 KB
testcase_27 AC 108 ms
16,092 KB
testcase_28 AC 114 ms
16,024 KB
testcase_29 AC 103 ms
16,024 KB
testcase_30 AC 99 ms
16,108 KB
testcase_31 AC 105 ms
16,216 KB
testcase_32 AC 103 ms
16,352 KB
testcase_33 AC 113 ms
16,056 KB
testcase_34 AC 109 ms
16,032 KB
testcase_35 AC 106 ms
16,036 KB
testcase_36 AC 110 ms
16,048 KB
testcase_37 AC 109 ms
15,992 KB
testcase_38 AC 105 ms
16,056 KB
testcase_39 AC 121 ms
16,020 KB
testcase_40 AC 124 ms
16,352 KB
testcase_41 AC 110 ms
16,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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