結果
問題 | No.2 素因数ゲーム |
ユーザー | Oland |
提出日時 | 2019-06-07 10:40:55 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 47 ms / 5,000 ms |
コード長 | 4,215 bytes |
コンパイル時間 | 2,051 ms |
コンパイル使用メモリ | 81,740 KB |
実行使用メモリ | 37,208 KB |
最終ジャッジ日時 | 2024-06-08 01:01:53 |
合計ジャッジ時間 | 4,250 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
37,148 KB |
testcase_01 | AC | 45 ms
36,972 KB |
testcase_02 | AC | 45 ms
37,064 KB |
testcase_03 | AC | 45 ms
37,024 KB |
testcase_04 | AC | 47 ms
37,100 KB |
testcase_05 | AC | 44 ms
36,880 KB |
testcase_06 | AC | 46 ms
36,988 KB |
testcase_07 | AC | 45 ms
37,140 KB |
testcase_08 | AC | 44 ms
37,052 KB |
testcase_09 | AC | 43 ms
36,892 KB |
testcase_10 | AC | 44 ms
37,208 KB |
testcase_11 | AC | 43 ms
37,128 KB |
testcase_12 | AC | 45 ms
37,048 KB |
testcase_13 | AC | 43 ms
37,084 KB |
testcase_14 | AC | 43 ms
37,156 KB |
testcase_15 | AC | 44 ms
37,008 KB |
testcase_16 | AC | 43 ms
37,084 KB |
testcase_17 | AC | 44 ms
36,972 KB |
testcase_18 | AC | 44 ms
37,100 KB |
testcase_19 | AC | 45 ms
36,748 KB |
testcase_20 | AC | 44 ms
36,892 KB |
testcase_21 | AC | 45 ms
36,712 KB |
testcase_22 | AC | 44 ms
37,036 KB |
testcase_23 | AC | 43 ms
36,988 KB |
testcase_24 | AC | 44 ms
37,000 KB |
testcase_25 | AC | 44 ms
36,892 KB |
testcase_26 | AC | 42 ms
36,892 KB |
testcase_27 | AC | 44 ms
37,208 KB |
testcase_28 | AC | 43 ms
36,972 KB |
testcase_29 | AC | 45 ms
36,932 KB |
testcase_30 | AC | 46 ms
36,916 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; @SuppressWarnings("unused") public class Main { String fileName = "input.txt"; final boolean isDebug = false; //final boolean isDebug = true; FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); final int MOD = (int)1e9+7; final long INF = Long.MAX_VALUE / 2; //final int INF = Integer.MAX_VALUE / 2; void solve() throws Exception{ long N = in.nextLong(); ArrayList<long[]> list = primeFactor(N); long xor = 0; for(long[] e : list){ xor ^= e[1]; } System.out.println(xor != 0 ? "Alice" : "Bob"); } ArrayList<long[]> primeFactor(long n){ ArrayList<long[]> list = new ArrayList<>(); for(long i = 2; i * i <= n; i++){ if(n % i == 0){ int cnt = 0; while (n % i == 0) { n /= i; cnt++; } list.add(new long[]{i, cnt}); } } if(n > 1) list.add(new long[]{n, 1}); return list; } /* end solve */ /* main */ public static void main(String[] args) throws Exception { new Main().m(); } void m() throws Exception { if(isDebug) in = new FastScanner(new FileInputStream(fileName)); solve(); out.flush(); } /* end main */ } /* end Main */ class UnionFind{ int[] par; int[] rank; int[] size; int group; UnionFind(int n){ par = new int[n]; rank = new int[n]; size = new int[n]; group = n; for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 0; size[i] = 1; } } //経路圧縮しながらrootを求める int find(int x){ if(par[x] == x){ return x; }else{ int f = find(par[x]); return par[x] = f; } } //ランクの小さいほうにつなげる boolean union(int x, int y, int w){ x = find(x); y = find(y); if(x == y) return false; if(rank[x] < rank[y]){ int tmp = x; x = y; y = tmp; w = -w; } //y(のroot)をx(のroot)の下にくっつける //yのほうが重くなる(ポテンシャルが高くなる) if(rank[x] == rank[y]) rank[x]++; group--; par[y] = x; size[x] += size[y]; return true; } boolean union(int x, int y){ return union(x, y, 0); } boolean isSame(int x, int y){ return find(x) == find(y); } } class FastScanner { Reader input; FastScanner() {this(System.in);} FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));} int nextInt() {return (int) nextLong();} long nextLong() { try { int sign = 1; int b = input.read(); while ((b < '0' || '9' < b) && b != '-' && b != '+') { b = input.read(); } if (b == '-') { sign = -1; b = input.read(); } else if (b == '+') { b = input.read(); } long ret = b - '0'; while (true) { b = input.read(); if (b < '0' || '9' < b) return ret * sign; ret *= 10; ret += b - '0'; } } catch (IOException e) { e.printStackTrace(); return -1; } } double nextDouble() { try { double sign = 1; int b = input.read(); while ((b < '0' || '9' < b) && b != '-' && b != '+') { b = input.read(); } if (b == '-') { sign = -1; b = input.read(); } else if (b == '+') { b = input.read(); } double ret = b - '0'; while (true) { b = input.read(); if (b < '0' || '9' < b) break; ret *= 10; ret += b - '0'; } if (b != '.') return sign * ret; double div = 1; b = input.read(); while ('0' <= b && b <= '9') { ret *= 10; ret += b - '0'; div *= 10; b = input.read(); } return sign * ret / div; } catch (IOException e) { e.printStackTrace(); return Double.NaN; } } char nextChar() { try { int b = input.read(); while (Character.isWhitespace(b)) { b = input.read(); } return (char) b; } catch (IOException e) { e.printStackTrace(); return 0; } } String nextStr() { try { StringBuilder sb = new StringBuilder(); int b = input.read(); while (Character.isWhitespace(b)) { b = input.read(); } while (b != -1 && !Character.isWhitespace(b)) { sb.append((char) b); b = input.read(); } return sb.toString(); } catch (IOException e) { e.printStackTrace(); return ""; } } }