m0_50903014 2021-07-17 16:24 采纳率: 0%
浏览 79

一道acm练习题为什么总是wrong answer

Alice and Bob like playing games. There are two piles of stones with numbers {n}n and {m}m. Alice and Bob take turns to operate, each operation can take away {k}(k>0)k(k>0) stones from one pile and take away s \times k(s \geq 0)s×k(s≥0) stones from another pile. Alice plays first. The person who cannot perform the operation loses the game.

Please determine who will win the game if both Alice and Bob play the game optimally.
输入描述:
The first line contains an integer T(1 \le T \le 10^4)T(1≤T≤10
4
) denotes the total number of test cases.
Each test case contains two integers n,m(1 \le n,m \leq 5 \times 10^3)n,m(1≤n,m≤5×10
3
) in a line, indicating the number of two piles of stones.
输出描述:
For each test case, print "Alice" if Alice will win the game, otherwise print "Bob".
示例1
输入
5
2 3
3 5
5 7
7 5
7 7

```c

include<stdio.h>
int main()
{
//ios::sync_with_stdio(false);cin.tie(0);
int a[5000][2]={{2,3},{5,7},{9,12},{14,18},{20,25},{27,33},{35,42},{44,52},{54,63},{65,75},{77,88},{90,102},{104,117},{119,133},{135,150},{152,168},{170,187},{189,207},{209,228},{230,250},{252,273},{275,297},{299,322},{324,348},{350,375},{377,403},{405,432},{434,462},{464,493},{495,525},{527,558},{560,592},{594,627},{629,663},{665,700},{702,738},{740,777},{779,817},{819,858},{860,900},{902,943},{945,987},{989,1032},{1034,1078},{1080,1125},{1127,1173},{1175,1222},{1224,1272},{1274,1323},{1325,1375},{1377,1428},{1430,1482},{1484,1537},{1539,1593},{1595,1650},{1652,1708},{1710,1767},{1769,1827},{1829,1888},{1890,1950},{1952,2013},{2015,2077},{2079,2142},{2144,2208},{2210,2275},{2277,2343},{2345,2412},{2414,2482},{2484,2553},{2555,2625},{2627,2698},{2700,2772},{2774,2847},{2849,2923},{2925,3000},{3002,3078},{3080,3157},{3159,3237},{3239,3318},{3320,3400},{3402,3483},{3485,3567},{3569,3652},{3654,3738},{3740,3825},{3827,3913},{3915,4002},{4004,4092},{4094,4183},{4185,4275},{4277,4368},{4370,4462},{4464,4557},{4559,4653},{4655,4750},{4752,4848},{4850,4947}};
//共97项
int N;
int m,n;
scanf("%d",&N);
int i;
char flag;
while(N--)
{
flag='A';
scanf("%d%d",&m,&n);
for(i=0;i<97;i++)
{
if((a[i][0]==m&&a[i][1]==n)||(a[i][0]==n&&a[i][1]==m))
{
flag='B';
continue;
}
}
if(flag=='A') printf("Alice\n");
else if(flag=='B') printf("Bob\n");
//else printf("ERROR");
}
return 0;
}
```#

  • 写回答

3条回答 默认 最新

  • CSDN专家-sinJack 2021-07-17 16:26
    关注

    全部执行不通过吗,看下执行结果。

    评论

报告相同问题?

问题事件

  • 创建了问题 7月17日

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器