結果

問題 No.1185 完全な3の倍数
ユーザー kk
提出日時 2020-11-07 02:13:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 204,908 KB
実行使用メモリ 8,820 KB
最終ジャッジ日時 2023-09-29 20:01:52
合計ジャッジ時間 4,956 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,144 KB
testcase_01 AC 20 ms
8,276 KB
testcase_02 AC 19 ms
7,536 KB
testcase_03 AC 19 ms
7,984 KB
testcase_04 AC 20 ms
8,064 KB
testcase_05 AC 19 ms
8,548 KB
testcase_06 AC 19 ms
7,328 KB
testcase_07 AC 19 ms
8,508 KB
testcase_08 AC 19 ms
8,056 KB
testcase_09 AC 19 ms
7,352 KB
testcase_10 AC 19 ms
7,788 KB
testcase_11 AC 20 ms
8,816 KB
testcase_12 AC 19 ms
7,972 KB
testcase_13 AC 19 ms
8,012 KB
testcase_14 AC 19 ms
7,856 KB
testcase_15 AC 20 ms
8,116 KB
testcase_16 AC 20 ms
8,676 KB
testcase_17 AC 19 ms
7,408 KB
testcase_18 AC 19 ms
8,016 KB
testcase_19 AC 20 ms
7,708 KB
testcase_20 AC 19 ms
8,508 KB
testcase_21 AC 19 ms
8,056 KB
testcase_22 AC 20 ms
8,512 KB
testcase_23 AC 20 ms
8,648 KB
testcase_24 AC 19 ms
7,408 KB
testcase_25 AC 19 ms
7,732 KB
testcase_26 AC 20 ms
8,816 KB
testcase_27 AC 19 ms
7,588 KB
testcase_28 AC 19 ms
7,504 KB
testcase_29 AC 20 ms
8,000 KB
testcase_30 AC 20 ms
8,804 KB
testcase_31 AC 20 ms
7,860 KB
testcase_32 AC 19 ms
7,796 KB
testcase_33 AC 19 ms
7,432 KB
testcase_34 AC 19 ms
7,508 KB
testcase_35 AC 19 ms
8,320 KB
testcase_36 AC 20 ms
8,820 KB
testcase_37 AC 20 ms
8,292 KB
testcase_38 AC 19 ms
7,640 KB
testcase_39 AC 20 ms
7,812 KB
testcase_40 AC 19 ms
7,792 KB
testcase_41 AC 20 ms
8,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

vector<long long> v;

void go(long long x) {
  if (x > 1e9) return;
  if (x >= 100) v.push_back(x);
  go(10 * x);
  go(10 * x + 3);
  go(10 * x + 6);
  go(10 * x + 9);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  for (int i = 10; i < 100; i++) {
    if (i % 3 == 0)
      v.push_back(i);
  }

  go(3);
  go(6);
  go(9);

  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  
  int n;
  cin >> n;
  int ret = upper_bound(v.begin(), v.end(), n) - v.begin();
  cout << ret << endl;

  return 0;
}
0