結果

問題 No.1185 完全な3の倍数
ユーザー mmn15277198mmn15277198
提出日時 2021-07-11 16:45:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 716 bytes
コンパイル時間 1,040 ms
コンパイル使用メモリ 103,148 KB
実行使用メモリ 22,608 KB
最終ジャッジ日時 2023-09-14 20:14:03
合計ジャッジ時間 4,624 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
20,988 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 100 ms
20,008 KB
testcase_04 AC 114 ms
22,608 KB
testcase_05 AC 107 ms
21,328 KB
testcase_06 AC 101 ms
20,508 KB
testcase_07 AC 99 ms
20,128 KB
testcase_08 RE -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 38 ms
8,416 KB
testcase_20 AC 94 ms
18,724 KB
testcase_21 AC 65 ms
13,744 KB
testcase_22 AC 45 ms
9,696 KB
testcase_23 AC 38 ms
8,440 KB
testcase_24 AC 93 ms
18,768 KB
testcase_25 AC 10 ms
4,748 KB
testcase_26 AC 65 ms
13,648 KB
testcase_27 AC 38 ms
8,520 KB
testcase_28 AC 69 ms
14,388 KB
testcase_29 AC 58 ms
12,280 KB
testcase_30 AC 66 ms
13,648 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 106 ms
21,244 KB
testcase_33 AC 22 ms
6,880 KB
testcase_34 AC 94 ms
18,656 KB
testcase_35 AC 114 ms
22,564 KB
testcase_36 AC 93 ms
18,908 KB
testcase_37 AC 93 ms
18,660 KB
testcase_38 AC 65 ms
13,532 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;

const long long MOD = (long long)(1e9) + 7;

map<string , int> mp;
long long n;
int d;

void dfs(string s) {
  if (s.size() > d) {
    return;
  }

  if ((long long)stoi(s) > n) {
    return;
  }

  mp[s]++;
  dfs(s + "3");
  dfs(s + "6");
  dfs(s + "9");
  dfs(s + "0");

  return;
}

int main() {

  //cout << fixed << setprecision(15);

  cin >> n;
  d = to_string(n).size();
  
  for (int i = 12; i <= min(99LL , n); i += 3) {
    mp[to_string(i)]++;
  }

  dfs("3");
  dfs("6");
  dfs("9");

  cout << mp.size() - 3 << endl;

  return 0;
}
0