結果
| 問題 | 
                            No.1140 EXPotentiaLLL!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-07-31 22:54:01 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 676 bytes | 
| コンパイル時間 | 1,156 ms | 
| コンパイル使用メモリ | 96,692 KB | 
| 最終ジャッジ日時 | 2025-01-12 11:12:20 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 WA * 5 TLE * 3 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:26: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
   36 |                 scanf("%ld %ld", &a, &p);
      |                        ~~^       ~~
      |                          |       |
      |                          |       ll* {aka long long int*}
      |                          long int*
      |                        %lld
main.cpp:36:30: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 3 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
   36 |                 scanf("%ld %ld", &a, &p);
      |                            ~~^       ~~
      |                              |       |
      |                              |       ll* {aka long long int*}
      |                              long int*
      |                            %lld
main.cpp:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |                 scanf("%ld %ld", &a, &p);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
using ll = long long;
using namespace std;
constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);
template<typename T>
bool is_prime(T n) {
	for(T i = 2; i * i <= n; ++i) {
		if( n % i == 0 ) return false;
	}
	
	return true;
}
int main(void) {
	int t;
	cin >> t;
	
	for(int i = 0; i < t; ++i) {
		ll a, p;
		scanf("%ld %ld", &a, &p);
		
		if( !is_prime(p) ) {
			printf("-1\n");
		} else {
			printf("1\n");
		}
	}
	
	return 0;
}