結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
![]() |
提出日時 | 2015-08-12 18:54:01 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,203 bytes |
コンパイル時間 | 3,588 ms |
コンパイル使用メモリ | 80,384 KB |
実行使用メモリ | 550,896 KB |
最終ジャッジ日時 | 2024-07-18 06:59:36 |
合計ジャッジ時間 | 43,894 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 RE * 1 MLE * 3 |
ソースコード
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class No0002 { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { int n = in.nextInt(); int x = 0; int[] primes = sieveOfEratosthenes(n+1); int ptr = 0; while (n != 1) { int cnt = 0; while (n%primes[ptr] == 0) { n /= primes[ptr]; cnt++; } x ^= cnt; ptr++; } out.println(x != 0 ? "Alice" : "Bob"); } static int[] sieveOfEratosthenes(int n) { if (n < 2) return null; boolean[] isPrime = new boolean[n]; Arrays.fill(isPrime,true); int[] res = new int[n]; int ptr = 0; isPrime[0] = isPrime[1] = false; for (int i=2; i<n; i++) { if (isPrime[i]) { res[ptr++] = i; for (int j=i+i; j<n; j+=i) isPrime[j] = false; } } return Arrays.copyOfRange(res,0,ptr); } public static void main(String[] args) { long start = System.currentTimeMillis(); solve(); out.flush(); long end = System.currentTimeMillis(); //trace(end-start + "ms"); in.close(); out.close(); } static void trace(Object... o) { System.out.println(Arrays.deepToString(o));} }