| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1040 人关注过本帖
标题:[求助]Elementary number theory --- gcd
只看楼主 加入收藏
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
 问题点数:0 回复次数:10 
[求助]Elementary number theory --- gcd
I have two natural numbers M and N, M>N, and gcd(M, N) = 1. I want to find integers x and y such that

x*M + y*N = 1.

Can you give me x and y in terms of M and N; i.e., express x or y as a function of M and N.

Thanks,

HJin


搜索更多相关主题的帖子: theory gcd number Elementary 
2007-06-21 08:42
tobyliying
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2007-4-16
收藏
得分:0 

gcd(M,N)=1
是什么意思

2007-06-21 10:47
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
gcd = greatest common divisor

For example,

gcd(4,8) = 4;
gcd(5, 16)=1.

I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-06-21 10:52
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
gcd = great common divisor(最大公约数)

这个问题似乎是个数学问题哦!有点复杂,我觉得可能要用到某些数学方程解.
关注下!


Fight  to win  or  die...
2007-06-21 11:58
tobyliying
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2007-4-16
收藏
得分:0 
fun(int M,int N)
{
int x,y;
for(int i=-M;i<M;i++)
{
for(int j=-M;j<M;j++)
{
x=i;
y=j;
if((x*M+y*N)==1)
{
cout<<"x:"<<x<<endl;
cout<<"y:"<<y<<endl;
}
}
}
}
main()
{
int M,N;
while(gcd(M,N)!=1||M<=N)
{
cin>>M>>N;
}
fun(M,N);
}
 我是这样做的
2007-06-21 11:58
tobyliying
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2007-4-16
收藏
得分:0 
用数学方法 我还没有想出来
2007-06-21 11:59
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
LS的
那个x.y的范围怎么就确认到 -M -- M -N -- N啊?
有依据吗?

[此贴子已经被作者于2007-6-21 12:02:39编辑过]


Fight  to win  or  die...
2007-06-21 12:01
tobyliying
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2007-4-16
收藏
得分:0 

这道题我想错了。. 对不起。.
这个方程的解是个解集

2007-06-21 14:29
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
Mathematics theory says that there exist x and y s.t.

x*M + y*N =1 if gcd(M, N)=1.

And I suspect that there are acutually infinitely many solutions for x and y.

You do not need to find all of them. I only want one of them, preferably expressed in terms of M and N.

Thanks.


I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-06-21 14:40
tobyliying
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2007-4-16
收藏
得分:0 
我睡了一觉后就想通了.

其中 M必然为奇数, N必然为偶数;

n为正整数,
当M=3 ,N=2时 x=1+2n, y=-(1+3n);
当M=5,N=4时 x=1+4n,y=-(1+5n);

就可以依次类推.
我相信可以写出相应的算法
2007-06-21 14:46
快速回复:[求助]Elementary number theory --- gcd
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014223 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved