awang01999's blog

By awang01999, history, 5 years ago, In English

Given a set of nonnegative integers a1, a2, ... an, Alice and Bob play a game with three rules

1) Alice goes first, and Bob goes next (they alternate turns)

2) A single turn consists of choosing some positive integer ai from the sequence, and replacing it with ai — d, where d is some divisor of ai.

3) When a player has no valid moves remaining, they lose.

Let's suppose (a1, a2, a3) = (1, 5, 4). Then on the first move Alice can make the list (1, 5, 2) by subtracting 2 from the third number (since 2 divides 4). Then Bob can get (1, 0, 2) by subtracting 5 from the middle number (5 divides 5), etc.

Let f(n, m) be the probability that Alice has a winning strategy for a random game with input integers (a1 ... an). where each ai is uniformly distributed on [0, m]. Given n and m, how can I write a program to compute the limit as n approaches infinity of f(n, m)?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By awang01999, history, 5 years ago, In English

Given a graph G = (V, E) with 1 <= N <= 100000 vertices and 1 <= M <= 100000 edges, how can I compute the minimum weighted path from vertex 1 to vertex N, where "weight" is defined as the exclusive bitwise XOR of all the edge weights?

For example if there is a graph with four vertices (call them 1, 2, 3) and 2 edges: one edge from 1 to 2 with weight 26, another edge from 2 to 3 with weight 18, then there's only one path from 1 to 3, so answer is 26 XOR 18 = 8.

I don't think most SSSP algorithms work here because XOR does not satisfy the triangle inequality. I was wondering whether anyone knows how to approach this problem.

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it