結果

問題 No.2725 Coprime Game 2
ユーザー kusaf_kusaf_
提出日時 2024-04-15 23:10:29
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 3,462 ms
コンパイル使用メモリ 274,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 23:10:35
合計ジャッジ時間 4,431 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 33 ms
5,376 KB
testcase_04 AC 47 ms
5,376 KB
testcase_05 AC 32 ms
5,376 KB
testcase_06 AC 27 ms
5,376 KB
testcase_07 AC 20 ms
5,376 KB
testcase_08 AC 29 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool solve()':
main.cpp:21:19: warning: 'p' may be used uninitialized [-Wmaybe-uninitialized]
   21 |   for(ll i = 1; i < p; i++) {
      |                 ~~^~~
main.cpp:13:6: note: 'p' was declared here
   13 |   ll p;
      |      ^

ソースコード

diff #

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

vector<ll> P = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};

bool solve() {
  ll N;
  cin >> N;

  if(N == 2) { return false; }

  ll p;
  for(auto &i : P) {
    if(N % i) {
      p = i;
      break;
    }
  }

  for(ll i = 1; i < p; i++) {
    if(N % i) { return false; }
  }

  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t;
  cin >> t;
  while(t--) { cout << (solve() ? "K" : "P") << "\n"; }
}
0