結果
| 問題 |
No.2 素因数ゲーム
|
| コンテスト | |
| ユーザー |
Oland
|
| 提出日時 | 2019-06-07 10:40:55 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 5,000 ms |
| コード長 | 4,215 bytes |
| コンパイル時間 | 2,645 ms |
| コンパイル使用メモリ | 81,712 KB |
| 実行使用メモリ | 37,260 KB |
| 最終ジャッジ日時 | 2024-12-26 13:55:53 |
| 合計ジャッジ時間 | 5,437 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
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 "";
}
}
}
Oland