Score(规律)
Score
Time Limit : 5000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 2 Accepted Submission(s) : 2
每组输入2个整数x, y(2<=x, y<=10^8),x=y=0表示输入结束
2 2
0 0
Inf
#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(规律)的更多相关文章
- [LeetCode] Score of Parentheses 括号的分数
Given a balanced parentheses string S, compute the score of the string based on the following rule: ...
- hdu6415 记忆化搜索或找规律
Rikka with Nash Equilibrium Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Sub ...
- 【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], ...
- Lucene的评分(score)机制研究
首先,需要学习Lucene的评分计算公式—— 分值计算方式为查询语句q中每个项t与文档d的匹配分值之和,当然还有权重的因素.其中每一项的意思如下表所示: 表3.5 评分公式中的因子 评分因子 描 述 ...
- hdu1452 Happy 2004(规律+因子和+积性函数)
Happy 2004 题意:s为2004^x的因子和,求s%29. (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...
- 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 ...
- ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)
//POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
随机推荐
- org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Internal Server Error 错误
Solr报错: { "responseHeader": { "status": 500, "QTime": 11 }, "erro ...
- php mysql 数据库写入与读取取文件
近期的项目由于特殊原因,需要将文件存到数据库中.今天特地测试,首先在php网站上传文件,将文件读取出来——再存入到MySQL数据库中. 一.首先创建php 代码如下(网上找了段代码进行过修改):源代码 ...
- php 解析xml 的四种方法(转)
XML处理是开发过程中经常遇到的,PHP对其也有很丰富的支持,本文只是对其中某几种解析技术做简要说明,包括:Xml parser, SimpleXML, XMLReader, DOMDocument. ...
- less做个径向菜单
在慕课网发现了一个有意思的课程,叫 数学知识在CSS动画中的应用 .用到的数学知识是如何计算圆上每个点的坐标.统一名称,中间的菜单叫触发菜单,四周发散的菜单叫子菜单, 效果预览 慕课网通过jquery ...
- CSS 基础总结
CSS基础 Doctype 声明位于文档中的最前面,处于 标签之前.告知浏览器的解析器,用什么文档类型 规范来解析这个文档. 在标准模式中,浏览器根据规范呈现页面: 在混杂模式中,页面以一种比较宽松的 ...
- ProFTPD 初探
ProFTPD:一个Unix平台上或是类Unix平台上(如Linux, FreeBSD等)的FTP服务器程序.
- 解决magento保存产品时耗时很长的问题
以前我在更新产品属性值(拿price为例)的时候,通常会这样做: foreach($product_ids as $id){ $product = Mage::getModel('catalog/pr ...
- BZOJ 1177 [Apio2009]Oil(递推)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1177 [题目大意] 给出一个矩阵,从中选出3个k*k且不相交的矩阵,使得其总和最大 [ ...
- linux下卸载安装程序及其配置的方法
首先要知道软件包的名字 dpkg --list 如果知道关键字的话可以用下面这种方法 dpkg --list|grep -i ‘packagename’ 找到所要删除的软件包之后 sudo apt-g ...
- 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 ...