提出 #4361095


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;

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

const char sp[] = {'7', '5', '3'};
set<int> all;

bool check(string& s) {
  int i,j;
  bool b[3];
  REP(i,3) b[i] = false;
  REP(i,s.length()) REP(j,3) if (s[i] == sp[j]) b[j] = true;
  return b[0] && b[1] && b[2];
}

void make(string& base) {
  if (base.length() >= 10) return;
  if (check(base)) {
    all.insert(stoi(base));
  }
  int i;
  REP(i,3) {
    string a = sp[i] + base;
    make(a);
  }
}

int main() {
  int N;

  string init = "";
  make(init);

  cin >> N;
  int res = 0;
  // for (const int& x : all) cout << x << endl;
  for (const int& x : all) if (x <= N) res++;
  cout << res << endl;

  return 0;
}

提出情報

提出日時
問題 C - 755
ユーザ jyane
言語 C++14 (GCC 5.4.1)
得点 300
コード長 762 Byte
結果 AC
実行時間 17 ms
メモリ 1536 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 20
セット名 テストケース
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20
ケース名 結果 実行時間 メモリ
a01 AC 16 ms 1536 KiB
a02 AC 16 ms 1536 KiB
a03 AC 16 ms 1536 KiB
b04 AC 16 ms 1536 KiB
b05 AC 16 ms 1536 KiB
b06 AC 16 ms 1536 KiB
b07 AC 16 ms 1536 KiB
b08 AC 16 ms 1536 KiB
b09 AC 16 ms 1536 KiB
b10 AC 16 ms 1536 KiB
b11 AC 17 ms 1536 KiB
b12 AC 16 ms 1536 KiB
b13 AC 16 ms 1536 KiB
b14 AC 17 ms 1536 KiB
b15 AC 16 ms 1536 KiB
b16 AC 16 ms 1536 KiB
b17 AC 16 ms 1536 KiB
b18 AC 16 ms 1536 KiB
b19 AC 16 ms 1536 KiB
b20 AC 16 ms 1536 KiB