結果

問題 No.889 素数!
ユーザー trineutrontrineutron
提出日時 2019-08-19 01:48:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 885 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 172,564 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-07 02:24:00
合計ジャッジ時間 2,825 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 35 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    vector<int> prime, square, cube, perfect = { 6, 28 };
    for (int i = 2; i < 64; i++) {
        if (i * i < 64) square.push_back(i * i);
        if (i * i * i < 64) cube.push_back(i * i * i);
        if (i == 2 || i == 3 || i == 5 || i == 7 || i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) prime.push_back(i);
    }
    int n;
    cin >> n;
    if (find(prime.begin(), prime.end(), n) != prime.end()) {
        cout << "素数!" << endl;
    } else if (find(square.begin(), square.end(), n) != square.end()) {
        cout << "平方数!" << endl;
    } else if (find(cube.begin(), cube.end(), n) != cube.end()) {
        cout << "立方数!" << endl;
    } else if (find(perfect.begin(), perfect.end(), n) != perfect.end()) {
        cout << "完全数!" << endl;
    } else {
        cout << n << endl;
    }
}
0