結果
問題 | No.2 素因数ゲーム |
ユーザー | threepipes_s |
提出日時 | 2015-10-05 18:54:49 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 2,381 bytes |
コンパイル時間 | 2,463 ms |
コンパイル使用メモリ | 80,128 KB |
実行使用メモリ | 51,884 KB |
最終ジャッジ日時 | 2024-06-08 00:12:53 |
合計ジャッジ時間 | 4,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
50,272 KB |
testcase_01 | AC | 54 ms
50,116 KB |
testcase_02 | AC | 53 ms
50,276 KB |
testcase_03 | AC | 50 ms
49,880 KB |
testcase_04 | AC | 52 ms
50,272 KB |
testcase_05 | AC | 53 ms
50,152 KB |
testcase_06 | AC | 52 ms
50,200 KB |
testcase_07 | AC | 53 ms
50,256 KB |
testcase_08 | AC | 55 ms
50,208 KB |
testcase_09 | AC | 54 ms
50,056 KB |
testcase_10 | AC | 54 ms
50,268 KB |
testcase_11 | AC | 52 ms
49,996 KB |
testcase_12 | AC | 53 ms
51,884 KB |
testcase_13 | AC | 54 ms
50,376 KB |
testcase_14 | AC | 55 ms
50,404 KB |
testcase_15 | AC | 54 ms
50,312 KB |
testcase_16 | AC | 52 ms
50,348 KB |
testcase_17 | AC | 52 ms
50,276 KB |
testcase_18 | AC | 53 ms
50,036 KB |
testcase_19 | AC | 52 ms
50,240 KB |
testcase_20 | AC | 54 ms
50,264 KB |
testcase_21 | AC | 53 ms
49,868 KB |
testcase_22 | AC | 53 ms
49,936 KB |
testcase_23 | AC | 53 ms
50,216 KB |
testcase_24 | AC | 53 ms
50,212 KB |
testcase_25 | AC | 53 ms
50,352 KB |
testcase_26 | AC | 52 ms
50,248 KB |
testcase_27 | AC | 53 ms
50,296 KB |
testcase_28 | AC | 52 ms
50,016 KB |
testcase_29 | AC | 53 ms
50,032 KB |
testcase_30 | AC | 53 ms
50,200 KB |
ソースコード
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.BitSet; import java.util.HashMap; public class Main{ public static void main(String[] args){ try { (new Solve()).solve(); } catch (NumberFormatException | IOException e) { e.printStackTrace(); } } } class Solve{ void solve() throws NumberFormatException, IOException{ final ContestScanner in = new ContestScanner(); int n = in.nextInt(); final int N = n; MultiSet<Integer> set = new MultiSet<>(); for(int i=2; i*i<=N; i++){ while(n%i==0){ set.add(i); n /= i; } } if(n > 1) set.add(n); int res = 0; for(int i: set.values()){ res ^= i; } System.out.println(res==0 ? "Bob" : "Alice"); } } class MultiSet<T> extends HashMap<T, Integer>{ @Override public Integer get(Object key) { if(this.containsKey(key)) return super.get(key); return 0; } public void add(T key){ if(this.containsKey(key)) super.put(key, super.get(key)+1); else super.put(key, 1); } public void add(T key, int val){ if(this.containsKey(key)) super.put(key, super.get(key)+val); else super.put(key, val); } } class ContestWriter{ private PrintWriter out; public ContestWriter(String filename) throws IOException{ out = new PrintWriter(new BufferedWriter(new FileWriter(filename))); } public ContestWriter() throws IOException{out = new PrintWriter(System.out);} public void println(String str){out.println(str);} public void print(String str){out.print(str);} public void close(){out.close();} } class ContestScanner{ BufferedReader reader; String[] line; int idx; public ContestScanner() throws FileNotFoundException{ reader = new BufferedReader(new InputStreamReader(System.in)); } public String nextToken() throws IOException{ if(line == null || line.length <= idx){ line = reader.readLine().trim().split(" "); idx = 0; } return line[idx++]; } public long nextLong() throws IOException, NumberFormatException{ return Long.parseLong(nextToken()); } public int nextInt() throws NumberFormatException, IOException{ return (int)nextLong(); } public double nextDouble() throws NumberFormatException, IOException{ return Double.parseDouble(nextToken()); } }