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的表(一)~表( ...
随机推荐
- C++ Member Functions的各种调用方式
[1]Nonstatic Member Functions(非静态成员函数) C++的设计准则之一就是:nonstatic member function至少必须和一般的nonmember funct ...
- PHP系列笔记——Zend_Controller工作流程
Zend_Controller_Front接收请求,然后调用Zend_Controller_Router_Rewrite来决定哪个控制器被派遣.为了在请求中设置控制器和动作名称,Zend_Contro ...
- MySQL 分区表各个分区的行数
分区的信息是记录在information_schema.partitions 这个表里的.它不能直接定位行所在的分区,但它可查到每个分区中有多少行. 例子: select partition_name ...
- 修改Eclipse的WorkSpace保持数[转载]
最近用Eclipse开发特别多,我个人习惯每一个项目一个WorkSpace,这样的话代码干净.而且当项目之前编码规范不一样时,也不会彼此影响.但项目一多,Eclipse默认只保存5个WorkSpace ...
- COB(Chip On Board) 工艺技术
COX(Chip On X) •X 基板: PCB (Printed circuit board) FPC (Flexible Printed Circuit) Glass •导线焊接 球形焊接 ...
- 让Java的反射跑快点
由于反射涉及动态解析的类型,某些Java虚拟机的优化不能被执行,所以导致了一定的性能的问题,特别是在JDK6以前特别严重,有时甚至达到数百倍,但是在JDK6以后,据说性能差别就不是哪么大了,JDK对此 ...
- 狼追兔子问题C模拟解
说,一只兔子在O点处,它的洞穴在正北20m的B点处,一只狼位于兔子正东33米的A点处,模拟如下追逐问题:狼以一倍于兔子的速度紧盯兔子追击,问兔子到达洞口前是否会被狼逮住? 网上很多人说能被追上,包括类 ...
- CentOS6.6普通用户使用sudo命令借用root用户权限
一.描写叙述 普通用户hadoop使用:tar -xzvf ns2.35.tar.gz命令解压文件,系统提示找不到该文件,无法打开该文件夹,于是想到使用sudo命令借用root用户的权限:sudo t ...
- Android Intent的几种使用方法全面总结
Intent应该算是Android中特有的东西.你能够在Intent中指定程序要运行的动作(比方:view,edit,dial),以及程序运行到该动作时所须要的资料.都指定好后,仅仅要调用startA ...
- golang printf
1: 打印包括字段在内的实例的完整信息 同 %+V fmt.Printf("Hello world! %v","hufeng") 输出:Hello world ...