Score

Time Limit : 5000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 2   Accepted Submission(s) : 2
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
题解;互素的时候等于inf,这个没啥问题,但是求最大不可能解的时候出现问题了,老在想着ax+by的x,y为正,就想找最小正整数,但是没有c就不会写了,看了网上的代码是个规律,不知道怎么得来的。。。。。a*b-a-b;
代码:
 #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long LL;
void e_gcd(LL a,LL b,LL &d,LL &x,LL &y){
if(!b){
d=a;
x=;y=;
}
else{
e_gcd(b,a%b,d,x,y);
LL temp=x;
x=y;
y=temp-a/b*y;
}
}
void cal(LL a,LL b){
LL d,x,y;
e_gcd(a,b,d,x,y);
//printf("%lld %lld %lld %lld\n",a,b,x,y);
if(d!=){
puts("Inf");
return;
}
/* if(b<0)b=-b;
LL ans=x%b;
//printf("%lld\n",x);
if(ans<0)ans+=b;
if(a<0)a=-a;
y%=a;
if(y<0)y+=a;
// printf("%lld %lld %lld\n",ans,t,y);
printf("%lld\n",max(a*ans-1,b*y-1);*/
printf("%lld\n",a*b-a-b);
}
int main(){
LL a,b;
while(~scanf("%lld%lld",&a,&b),a|b){
cal(a,b);
}
return ;
}
 

Score(规律)的更多相关文章

  1. [LeetCode] Score of Parentheses 括号的分数

    Given a balanced parentheses string S, compute the score of the string based on the following rule: ...

  2. hdu6415 记忆化搜索或找规律

    Rikka with Nash Equilibrium Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Sub ...

  3. 【leetcode】Smallest Rotation with Highest Score

    题目如下: Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], ...

  4. Lucene的评分(score)机制研究

    首先,需要学习Lucene的评分计算公式—— 分值计算方式为查询语句q中每个项t与文档d的匹配分值之和,当然还有权重的因素.其中每一项的意思如下表所示: 表3.5 评分公式中的因子 评分因子 描 述 ...

  5. hdu1452 Happy 2004(规律+因子和+积性函数)

    Happy 2004 题意:s为2004^x的因子和,求s%29.     (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...

  6. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

  7. ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)

    //POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...

  8. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

  9. 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

随机推荐

  1. egret命令行编译项目时 版本不对应的问题

    egret 命令行编译项目时 如使用 egret build -e 会出现版本不对应的问题 分析原因 A,B项目 A项目使用1.8的egret引擎, B项目使用2.5引擎 但本地引擎升级至2.5.5, ...

  2. Common Git command and mean (Windows)

    Config: git config --system git config --global git config --global merge.tool vimdiff Check config: ...

  3. java中常用的数据加密算法

    以下为加密的工具类: import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; im ...

  4. MYSQL alter procedure alter function 它们只可以更改过程的特性,不可以更改过程的逻辑。

    例子: delimiter // create procedure proc_a(in numberA int) 这样create procedure 是正确的 begin select number ...

  5. Linux下查看内核、CPU、内存及各组件版本的命令和方法

    Linux下查看内核.CPU.内存及各组件版本的命令和方法 Linux查看内核版本: uname -a                        more /etc/*release       ...

  6. Pro/E 5.0安装图解教程(也适用于Creo Elements/Pro 5.0)

    安装前必读:☆ 本教程适用于 32 位 proe 5.0 M010,M020,M030,M040,M050,M060 过程完全一样:☆ 本教程用于 64 位 proe 5.0 M010,M020,M0 ...

  7. 编程实现Windows系统自动登录

    编程实现Windows系统自动登录 原理: 通过注册表修改实现.Windows内置了自动登录的机制,在登录系统时,winlogon会检查注册表下有没有设置自动登录,如果设置了就上就会读取用户名和密码, ...

  8. PASCAL的读入优化

    没readkey的情况 type Tstring=record s:array[0..maxn] of char; n:longint; end; procedure scan(var S:Tstri ...

  9. FastCGI | FastCGI -

    FastCGI | FastCGI - FastCGI About FastCGI FastCGI is simple because it is actually CGI with only a f ...

  10. java开发工具比较(16个工具修订版)

    1.JDK (Java Development Kit)Java开发工具集 SUN的Java不仅提了一个丰富的语言和运行环境,而且还提了一个免费的Java开发工具集(JDK).开发人员和最终用户可以利 ...