青蛙的约会 java版

参考http://blog.csdn.net/polossk/article/details/9799735

package acm;

public class FrogDate {

    public static void main(String[] args) {

        int x = ,y = ,m = ,n = ,l = ;
int ar=n-m,br=,cr=x-y;
int M = exGcd(n-m,l,ar,br); System.out.println("M:" + M); if((x-y)%M!= || m==n)
System.out.println("Impossible");
else{
int s=l/M;
ar=ar*((x-y)/M); ar=(ar%s+s)%s;
System.out.println("ar : " + ar);
}
} static int Gcd(int a, int b)
{
while(b != )
{
int r = b;
b = a % b;
a = r;
}
return a;
} static int exGcd(int a, int b, int x, int y)
{
if(b == )
{
x = ;
y = ;
return a;
}
int r = exGcd(b, a % b, x, y);
int t = x;
x = y;
y = t - a / b * y;
return r;
} }
上一篇:bzoj1875


下一篇:Web前端 css实现元素垂直居中的常用方法