結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
21,108 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 101 ms
20,000 KB
testcase_04 AC 116 ms
22,660 KB
testcase_05 AC 108 ms
21,276 KB
testcase_06 AC 103 ms
20,312 KB
testcase_07 AC 101 ms
20,064 KB
testcase_08 RE -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 39 ms
8,604 KB
testcase_20 AC 93 ms
18,724 KB
testcase_21 AC 65 ms
13,724 KB
testcase_22 AC 45 ms
9,776 KB
testcase_23 AC 38 ms
8,520 KB
testcase_24 AC 93 ms
18,728 KB
testcase_25 AC 10 ms
4,676 KB
testcase_26 AC 65 ms
13,656 KB
testcase_27 AC 37 ms
8,500 KB
testcase_28 AC 69 ms
14,272 KB
testcase_29 AC 59 ms
12,444 KB
testcase_30 AC 66 ms
13,704 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 108 ms
21,280 KB
testcase_33 AC 21 ms
6,960 KB
testcase_34 AC 94 ms
18,764 KB
testcase_35 AC 113 ms
22,580 KB
testcase_36 AC 94 ms
19,048 KB
testcase_37 AC 94 ms
18,860 KB
testcase_38 AC 65 ms
13,604 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 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;
int n , d;

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

  if ((int)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(99 , n); i += 3) {
    mp[to_string(i)]++;
  }

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

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

  return 0;
}
0