結果

問題 No.207 世界のなんとか
ユーザー Luna
提出日時 2018-05-07 16:05:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 644 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 58,456 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 02:17:15
合計ジャッジ時間 1,232 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

inline int powi(int n, int m) {
    int product = 1;
    for (int i = 0; i < m; i++) {
        product *= n;
    }
    return product;
}

inline bool check_three(int n) {
    int digit, unit;

    if (n % 3 == 0) return true;

    digit = log10(n) + 1;
    for (int i = 0; i < digit; i++) {
        unit = n % powi(10, i+1) / powi(10, i);
        if (unit == 3) return true;
    }

    return false;
}

int main(int argc, char const* argv[]) {
    int A, B;

    cin >> A >> B;

    for (int i = A; i < B+1; i++) {
        if (check_three(i)) cout << i << endl;
    }
    return 0;
}
0