Submission #3704291


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

long long ito357(long long n) {
    int ch[4] = {0, 3, 5, 7};
    long long ans = 0;
    int i = 0;
    while (n > 0) {
        long long f = ch[n % 4];
        for (int j = 0; j < i; j++) f *= 10;
        ans += f;
        i++;
        n /= 4;
    }
    return ans;
}

bool is_valid(long long n357) {
    if (n357 < 357) return false;
    string s = to_string(n357);
    bool v[3] = {false, false, false};
    for (char &c : s) {
        if (c == '3')
            v[0] = true;
        else if (c == '5')
            v[1] = true;
        else if (c == '7')
            v[2] = true;
        else
            return false;
    }
    return v[0] && v[1] && v[2];
}

int main() {
    
    long long n;
    cin >> n;
    
    if (n < 357) {
        cout << 0 << endl;
        return 0;
    }
    
    long long ans = 0;
    for (int i = 0; ; i++) {
        long long n357 = ito357(i);
        if (n < n357) break;
        if (!is_valid(n357)) continue;
        ans++;
    }
    
    cout << ans << endl;
    
}

Submission Info

Submission Time
Task C - 755
User ganmodokix
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1201 Byte
Status AC
Exec Time 53 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
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
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 53 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 1 ms 256 KB
b14 AC 3 ms 256 KB
b15 AC 7 ms 256 KB
b16 AC 18 ms 256 KB
b17 AC 27 ms 256 KB
b18 AC 53 ms 256 KB
b19 AC 53 ms 256 KB
b20 AC 53 ms 256 KB