結果

問題 No.1185 完全な3の倍数
ユーザー ktr216
提出日時 2020-08-22 13:29:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 166,312 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 09:19:29
合計ジャッジ時間 2,341 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    int N, ans = 0;
    cin >> N;
    for (int i = 10; i < 100; i++) {
        if (i > N) {
            cout << ans << "\n";
            return 0;
        }
        if (i % 3 == 0) ans++;
    }
    for (int i = 16; i < 1048576; i++) {
        ll x = 0, y = 1, z = i;
        while (z > 0) {
            x += y * 3 * (z % 4);
            y *= 10;
            z /= 4;
        }
        //cout << x << "\n";
        if (x > N) {
            cout << ans << "\n";
            return 0;
        }
        ans++;
    }
}
0