10812 - Beat the Spread!
Time limit: 3.000 seconds
蛋碎了,被水题坑到了。。
完整代码:
/*0.018s*/
#include<cstdio>
int main()
{
int t, s, d;
scanf("%d", &t);
while (t--)
{
scanf("%d%d", &s, &d);
if (s < d || (s + d) & 1) puts("impossible");
else printf("%d %d\n", (s + d) >> 1, (s - d) >> 1);
}
return 0;
}

本文介绍了一个UVa在线评测系统中的算法题目“10812-BeattheSpread!”的解决方案。该题需要判断给定的两个整数s和d是否能构成一个合法的分数,并给出分子分母的值。文章提供了一段简洁高效的C++代码实现。
1499

被折叠的 条评论
为什么被折叠?



