nyoj 408 Board Game Dice

版权声明:本文为博主原创文章,转载需注明出处。 https://blog.csdn.net/Hearthougan/article/details/24921175


题意:给定n, m,问当m的x次方大于等于n时,(m^x * x)与n的真分数是多少。


typedef long long LL;

LL  gcd(LL a, LL b)//*这就是那个求最大公约数的函数。一个模版。*//
	if(b == 0)
        return a;
	return gcd(b,a%b);

int main()
    LL temp, n, m, tmp;
	int T,i,j, kcase = 1;
	scanf("%d", &T);
	   scanf("%lld %lld",&n,&m);
	   tmp = 1, i = 0;
           tmp *= m;
           if(tmp >= n)
	   tmp *= i;
	   temp = gcd(tmp, n);
	   tmp = tmp/temp;
	   n = n/temp;
	   printf("Case %d: %lld/%lld\n", kcase++, tmp, n);
	return 0;

Board Game


DescriptionnnAlice and Bob started to play the following game: they have an m×n chessboard, with some of the fields removed. There are two chess pieces on distinct (non-removed) fields of the board. Alice always makes the first move and then she alternates with Bob in turns. Each turn consists of moving one of the pieces by one field horizontally or vertically. Both players can move any of the pieces, regardless of the piece moved in the previous turn. The piece cannot be moved to a removed field. The player that is able to move one of the pieces to the field occupied by the other one, thus capturing it, wins. nnAfter some time, they found the game very boring -- nobody could win, and the pieces just chased each other around the board. Therefore, they introduced a new rule -- no player may move a piece in such a way that a position that already appeared during the game is repeated. The position is considered to be the same if the fields occupied by the pieces are the same (the pieces cannot be distinguished), regardless of who is on turn in the particular position. Additionally, they introduced a rule that the player who cannot make a legal move loses. Now the game is always finite and one of the players will surely win. Your goal is to find a winning strategy, if one exists. nnInputnnThe input consists of several instances, separated by single empty lines. nnThe first line of each instance consists of two integers m and n, 1 m, n 8. Each of m following lines consists of n characters and determines the initial state of the chessboard. The characters are one of the following:n"." for an empty field of the chessboardn"#" for a removed field of the chessboardn"P" for the field of the chessboard where one of the pieces startsnThere are always precisely two characters "P" in each instance.nOutputnnThe output for each instance consists of a single line containing either the string "Alice wins." if Alice has a winning strategy in the described position, or the string "Bob wins.", if she has no such strategy.nSample Inputnn4 4nP.##n..##n##..n##.Pnn1 5nP...PnSample OutputnnAlice wins.nBob wins.


  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他