您的位置:首页 > 其它

数学概念——I - 数论,线性方程

2015-08-22 16:05 260 查看
I - 数论,线性方程
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status

Description

The Sky is Sprite.
The Birds is Fly in the Sky.
The Wind is Wonderful.
Blew Throw the Trees
Trees are Shaking, Leaves are Falling.
Lovers Walk passing, and so are You.
................................Write in English class by yifenfei

#include <cstdio>
using namespace std;
int x,y;
int gcd(int a,int b)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
int d=gcd(b,a%b);
int r=x;
x=y;
y=r-(a/b)*y;
return d;
}
}
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)==2)
{
int d=gcd(a,b);
if(d!=1)
printf("sorry\n");
else
{
while(x<=0)
{
x=x+b;
y=y-a;
}
printf("%d %d\n",x,y);
}
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: