hdu 5924 Mr. Frog’s Problem (签到题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5924

给你一个a和b,找出所有的c和d满足a/b+b/a<=c/d+d/c  而且a<=c<=b,a<=d<=b。

可以简单推得,满足这个情况的只有a,b和b,a。所有只需要判断一下a和b是否相等就行了

注意ll  

#pragma GCC optimize(2)
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
const int maxn = 500;
const int inf = 0x3f3f3f3f;
typedef long long ll;
int main()
{
	//freopen("C://input.txt", "r", stdin);
	int t;
	scanf("%d", &t);
	int cnt = 1;
	while (t--)
	{
		ll n, m;
		scanf("%lld%lld", &n, &m);
		if (n > m)
		{
			swap(n, m);
		}
		printf("Case #%d:\n", cnt++);
		if (n == m)
		{
			printf("1\n");
			printf("%lld %lld\n", n, m);
		}
		else
		{
			printf("2\n");
			printf("%lld %lld\n", n, m);
			printf("%lld %lld\n", m, n);
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Evildoer_llc/article/details/82928565