题目要求:
输入代码:
#include
typedef long l;//定义长整形,省时省力
using namespace std;
int gcd(l a,l b)//最大公约数算法
{
l r;
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
return a;
...
分类:
其他好文 时间:
2015-08-26 18:00:41
阅读次数:
180
public?class?Main{
?/**
??*?@param?args
??*/
?public?static?void?main(String[]?args)?{
??//?TODO?Auto-generated?method?stub
??Scanner?scan?=?new?Scanner(System.in);
??i...
分类:
其他好文 时间:
2015-08-25 13:03:25
阅读次数:
225
最大公约数DescriptionThere is a hill with n holes around. The holes are signed from 0 to n-1.A rabbit must hide in one of the holes. A wolf searches the ra...
分类:
其他好文 时间:
2015-08-21 19:20:41
阅读次数:
154
题意:对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数。1≤n≤50000,1≤a≤b≤50000,1≤c≤d≤50000,1≤k≤50000思路:莫比乌斯反演,ans=solve(b/k,d/k)-s...
分类:
其他好文 时间:
2015-08-20 12:07:24
阅读次数:
188
DescriptionThere is a hill with n holes around. The holes are signed from 0 to n-1.A rabbit must hide in one of the holes. A wolf searches the rabbit ...
分类:
其他好文 时间:
2015-08-20 09:08:36
阅读次数:
106
int GCD(int aa,int bb)
{
int i,t;
if(aai){
aa=bb;
bb=i;
}
else aa=i;
}
return bb;
}
ll LCM(int aa,int bb)
{
int ...
分类:
其他好文 时间:
2015-08-19 23:44:33
阅读次数:
141
一、欧几里德算法:即辗转相除法,用于求两个整数a,b的最大公约数见:最大公约数模板二、扩展欧几里德算法:对于不完全为0的非负整数a,b,gcd(a,b)表示a,b的最大公约数,必然存在整数对x,y,使得gcd(a,b)=ax+by。kb2.3扩展欧几里德算法(求ax+by=gcd的解以及逆元)#in...
分类:
编程语言 时间:
2015-08-19 19:09:10
阅读次数:
117
G -数论,最大公约数Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionThere is a hill with n holes around. The holes are...
分类:
其他好文 时间:
2015-08-18 20:59:26
阅读次数:
113
题目给你两个正整数a和b, 输出它们的最大公约数辗转相除法辗转相除法的步骤def gcd(b,a):
b,a=a,b%a
if a==0:
return b
else:
return gcd(b,a)即就是取如果b与a不能整除,就取a和b除以a的余数再考察是个递归的思路。理解可以从两个角度去理解辗转相除法1.举例法一张长方形纸,长2703厘米,...
分类:
编程语言 时间:
2015-08-18 19:31:36
阅读次数:
146
G -数论,最大公约数Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uDescriptionThere is a hill with n holes around. The holes are signed from...
分类:
其他好文 时间:
2015-08-18 18:21:03
阅读次数:
114