結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2020-07-31 22:07:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 673 bytes |
コンパイル時間 | 562 ms |
コンパイル使用メモリ | 68,800 KB |
実行使用メモリ | 16,960 KB |
最終ジャッジ日時 | 2024-07-06 18:18:38 |
合計ジャッジ時間 | 7,454 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 11 |
ソースコード
#include <iostream> #include <math.h> using namespace std; bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } int main(){ int n; cin >> n; for (int i = 0; i < n; i++){ long long a; int p; cin >> a >> p; if (IsPrime(p)) cout << -1 << endl; else cout << 1 << endl; } }