結果

問題 No.3079 アルベド
ユーザー Cyclone28Cyclone28
提出日時 2021-04-08 21:09:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 166,448 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 05:03:06
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
4,380 KB
testcase_01 AC 144 ms
4,380 KB
testcase_02 AC 98 ms
4,376 KB
testcase_03 AC 68 ms
4,376 KB
testcase_04 AC 115 ms
4,380 KB
testcase_05 AC 88 ms
4,376 KB
testcase_06 AC 108 ms
4,380 KB
testcase_07 AC 30 ms
4,380 KB
testcase_08 AC 38 ms
4,380 KB
testcase_09 AC 84 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

bool is_prime(int p){
    if(p == 1) return false;
    for(int i = 2; i <= sqrt(p); i++){
        if(p % i == 0) return false;
    }
    return true;
}

int main(){
    vector<int> a(100001);
    int cnt = 0;
    for(int i = 1; i <= 100000; i++){
        if(is_prime(i)) cnt++;
        a[i] = cnt;
    }
    int t; cin >> t;
    for(int i = 0; i < t; i++){
        int n; cin >> n;
        cout << a[n] << endl;
    }
}
0