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. org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Internal Server Error 错误

    Solr报错: { "responseHeader": { "status": 500, "QTime": 11 }, "erro ...

  2. php mysql 数据库写入与读取取文件

    近期的项目由于特殊原因,需要将文件存到数据库中.今天特地测试,首先在php网站上传文件,将文件读取出来——再存入到MySQL数据库中. 一.首先创建php 代码如下(网上找了段代码进行过修改):源代码 ...

  3. php 解析xml 的四种方法(转)

    XML处理是开发过程中经常遇到的,PHP对其也有很丰富的支持,本文只是对其中某几种解析技术做简要说明,包括:Xml parser, SimpleXML, XMLReader, DOMDocument. ...

  4. less做个径向菜单

    在慕课网发现了一个有意思的课程,叫 数学知识在CSS动画中的应用 .用到的数学知识是如何计算圆上每个点的坐标.统一名称,中间的菜单叫触发菜单,四周发散的菜单叫子菜单, 效果预览 慕课网通过jquery ...

  5. CSS 基础总结

    CSS基础 Doctype 声明位于文档中的最前面,处于 标签之前.告知浏览器的解析器,用什么文档类型 规范来解析这个文档. 在标准模式中,浏览器根据规范呈现页面: 在混杂模式中,页面以一种比较宽松的 ...

  6. ProFTPD 初探

    ProFTPD:一个Unix平台上或是类Unix平台上(如Linux, FreeBSD等)的FTP服务器程序.

  7. 解决magento保存产品时耗时很长的问题

    以前我在更新产品属性值(拿price为例)的时候,通常会这样做: foreach($product_ids as $id){ $product = Mage::getModel('catalog/pr ...

  8. BZOJ 1177 [Apio2009]Oil(递推)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1177 [题目大意] 给出一个矩阵,从中选出3个k*k且不相交的矩阵,使得其总和最大 [ ...

  9. linux下卸载安装程序及其配置的方法

    首先要知道软件包的名字 dpkg --list 如果知道关键字的话可以用下面这种方法 dpkg --list|grep -i ‘packagename’ 找到所要删除的软件包之后 sudo apt-g ...

  10. JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what webkit inspector and firebug do)

    JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what ...