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的表(一)~表( ...
随机推荐
- egret命令行编译项目时 版本不对应的问题
egret 命令行编译项目时 如使用 egret build -e 会出现版本不对应的问题 分析原因 A,B项目 A项目使用1.8的egret引擎, B项目使用2.5引擎 但本地引擎升级至2.5.5, ...
- Common Git command and mean (Windows)
Config: git config --system git config --global git config --global merge.tool vimdiff Check config: ...
- java中常用的数据加密算法
以下为加密的工具类: import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; im ...
- MYSQL alter procedure alter function 它们只可以更改过程的特性,不可以更改过程的逻辑。
例子: delimiter // create procedure proc_a(in numberA int) 这样create procedure 是正确的 begin select number ...
- Linux下查看内核、CPU、内存及各组件版本的命令和方法
Linux下查看内核.CPU.内存及各组件版本的命令和方法 Linux查看内核版本: uname -a more /etc/*release ...
- 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 ...
- 编程实现Windows系统自动登录
编程实现Windows系统自动登录 原理: 通过注册表修改实现.Windows内置了自动登录的机制,在登录系统时,winlogon会检查注册表下有没有设置自动登录,如果设置了就上就会读取用户名和密码, ...
- PASCAL的读入优化
没readkey的情况 type Tstring=record s:array[0..maxn] of char; n:longint; end; procedure scan(var S:Tstri ...
- FastCGI | FastCGI -
FastCGI | FastCGI - FastCGI About FastCGI FastCGI is simple because it is actually CGI with only a f ...
- java开发工具比较(16个工具修订版)
1.JDK (Java Development Kit)Java开发工具集 SUN的Java不仅提了一个丰富的语言和运行环境,而且还提了一个免费的Java开发工具集(JDK).开发人员和最终用户可以利 ...