Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:这组数据输出 -1 都过了,,,,,,,,,,无语

Posted by q1739281899 at 2021-09-22 11:35:28 on Problem 1061
In Reply To:这组数据输出 -1 都过了,,,,,,,,,,无语 Posted by:leiyongZL at 2016-08-01 08:37:16
> #include<iostream>
> #include<stdio.h>
> #include<cmath>
> using namespace std;
> long long int gcd(long long int a,long long int b,long long int &x,long long int &y){
>     if (b==0){
>         x=1,y=0;
>         return a;
>     }
>     int q=gcd(b,a%b,y,x);
>     y-=a/b*x;
>     return q;
> }
> int main()
> {
>     long long int x,y,m,n,l;
>     while(scanf("%I64d%I64d%I64d%I64d%I64d",&x,&y,&m,&n,&l)!=EOF)
>     {
>         long long int a=(n-m),c=(x-y),x0,y0;
>         long long int g=gcd(a,l,x0,y0);
>         if(n==m||c%g!=0)
>         {
>           cout<<"Impossible"<<endl;
>         }else
>         {
>             x0=x0*(c/g);
>             int b=l/g;
>             x0=(x0%b+b)%b;
>             cout<<x0<<endl;
>         }
>     }
>     return 0;
> }
> 
> 
> 9 8 7 6 4
> 
> -1

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator