結果

問題 No.2 素因数ゲーム
ユーザー OlandOland
提出日時 2019-06-07 10:40:55
言語 Java19
(openjdk 21)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 4,215 bytes
コンパイル時間 2,534 ms
コンパイル使用メモリ 78,768 KB
実行使用メモリ 49,816 KB
最終ジャッジ日時 2023-08-27 05:06:12
合計ジャッジ時間 5,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,360 KB
testcase_01 AC 42 ms
49,280 KB
testcase_02 AC 44 ms
49,528 KB
testcase_03 AC 43 ms
49,184 KB
testcase_04 AC 45 ms
49,808 KB
testcase_05 AC 43 ms
49,332 KB
testcase_06 AC 43 ms
49,516 KB
testcase_07 AC 42 ms
49,380 KB
testcase_08 AC 43 ms
49,540 KB
testcase_09 AC 43 ms
49,816 KB
testcase_10 AC 43 ms
49,188 KB
testcase_11 AC 43 ms
49,292 KB
testcase_12 AC 44 ms
49,376 KB
testcase_13 AC 43 ms
49,344 KB
testcase_14 AC 43 ms
49,760 KB
testcase_15 AC 42 ms
49,620 KB
testcase_16 AC 42 ms
49,816 KB
testcase_17 AC 43 ms
49,512 KB
testcase_18 AC 43 ms
49,540 KB
testcase_19 AC 43 ms
49,452 KB
testcase_20 AC 43 ms
49,552 KB
testcase_21 AC 44 ms
49,812 KB
testcase_22 AC 43 ms
49,352 KB
testcase_23 AC 43 ms
49,556 KB
testcase_24 AC 43 ms
47,404 KB
testcase_25 AC 44 ms
49,472 KB
testcase_26 AC 44 ms
49,656 KB
testcase_27 AC 44 ms
49,536 KB
testcase_28 AC 42 ms
49,348 KB
testcase_29 AC 43 ms
49,372 KB
testcase_30 AC 42 ms
49,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 "";
		}
	}
}
0