HDU 2534 Score

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=2534

Problem Description

大家都知道,pfz是“成电杰出学生”,在成电杰出学生的颁奖典礼上,lxh和pfz都没有听台上在说什么,而是在下面讨论当晚的美式足球比赛,lxh预测说纽约巨人队今晚将会得到11分,pfz马上说不可能。因为通常来说美式足球比赛的得分只有3分和7分两种形式,无论怎么得分都不可能得到11分。想了一会以后,lxh发现其实11分以上的分数都是可以得到,于是11就是最大的不可以得到的分数。现在问题来了,如果比赛的得分只有x分和y分两种形式,那么最大的不可以得到的分数是多少呢?

Input

本题包括多组输入
每组输入2个整数x, y(2<=x, y<=10^8),x=y=0表示输入结束

Output

对于每组输入,输出一行,若存在一个最大的不可以得到的分数,则输出此分数,否则输出Inf

Sample Input

3 7

2 2

0 0

Sample Output

11

Inf

Hint:

题意:

中文。

题解:

本题有计算的公式,当gcd=1的时候,答案为n*m-n-m。其他的情况下就为inf。

代码:

#include <cstdio>
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
int main()
{
    ll n,m;
    while(scanf("%lld%lld",&n,&m)!=EOF&&n!=0&&m!=0)
    {
        if(gcd(n,m)==1)
            printf("%lld\n",n*m-n-m);
        else
            printf("Inf\n");
    }
}
时间: 2024-10-31 18:18:40

HDU 2534 Score的相关文章

HDOJ(HDU) 2148 Score(比较、)

Problem Description 转眼又到了一年的年末,Lele又一次迎来了期末考试.虽然说每年都要考试,不过今年的这场考试对Lele来说却意义重大. 因为经济原因,如果今年没有排在班级前几名,而拿不到奖学金的话,家里便无力再供他继续读书.而且家里帮他都想好出路了--回家种田!! 虽说Lele心里有一百个不愿意,不过父母的话不能不听. 忐忑不安地考完试,Lele拿到了全班的成绩单,这张成绩单是按学号顺序排好的.Lele很想知道班里到底有多少人分数比他高,现在就请你帮帮他,帮他数一下到底有多

hdu 5268 ZYB loves Score 水题

ZYB loves Score Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5268 Description One day,ZYB participated in the BestCoder Contest There are four problems. Their scores are 1000,1500,2000,2500 According to the r

HDU 5268 ZYB loves Score (BestCoder Round#44)

题目链接:ZYB loves Score 题面: ZYB loves Score Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 395    Accepted Submission(s): 232 Problem Description One day,ZYB participated in the BestCoder Contest

HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)

Problem Description The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges that

HDU 5268 ZYB loves Score (简单模拟,水)

题意:计算Bestcoder四题的得分. 思路:直接模拟,4项分数直接计算后输出.注意不要低于百分之40的分. 1 //#include <bits/stdc++.h> 2 #include <iostream> 3 #include <cstdio> 4 #define LL long long 5 using namespace std; 6 const int N=10; 7 int a[N]; 8 int b[N]; 9 10 int cal() 11 { 12

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

HDU 1087 Super Jumping! Jumping! Jumping! 简单DP

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意:N个数字组成的一条路,每个数字是一个节点顺序连接,起点在第一个数之前,终点在第N个数之后.现让你选择一条路从起点跳到终点,只能往前且跳到比当前点大的那个点,可以认为终点是最大的,可以从起点直接跳到终点但是路的值就是0了,每条路的值为所经过的数字节点的值的和,问你值最大为多少. 解题思路:决策:在当前点i往i~N哪个点跳,反过来当前点i+1可以从1~i哪个点跳过来,那么a[i+1] >

HDU 1113 Word Amalgamation (map 容器 + string容器)

http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in th

hdu 1087 Super Jumping! Jumping! Jumping!(最大上升子序列和)

Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 36986    Accepted Submission(s): 16885 Problem Description Nowadays, a kind of chess game called “Super Jumping!