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

哪里有错,runtime error

Posted by wangmj17 at 2012-04-23 20:41:47 on Problem 2115
#include<stdio.h>
#include<iostream>
#include<time.h>
#include<string.h>
using namespace std;
long long g[33],x,y,e;
bool gcd(long long a,long long b,long long c)
{
     if(a==0)
     {
             if(c%b==0)
             {
                       e=b;
                   x=0,y=c/b;
                   return true;    
             }
             return false;
     }
     if(!gcd(b%a,a,c))return false;
     long long x2=x,y2=y;
     y=x2;
     x=y2-(b/a)*x2;
     return true;
}
int main()
{
    long long a,b,c,k,i;
    g[0]=1;
    for(i=1;i<=32;i++)
    g[i]=g[i-1]*2;
    while(1)
    {
          scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&k);  
          if(a==0&&b==0&&c==0&&k==0)break;
          if(!gcd(g[k],c,b-a))printf("FOREVER\n");
          else 
          {
               if(e!=0)
               {
               long long d=c*g[k]/e;
               if(y<0)
               {y+=(-y)/(d/c)*(d/c);if(y<0)y+=d/c;}
               else
               y-=y/(d/c)*(d/c);
               }
               printf("%I64d\n",y); 
          }
    }
    
    return 0;
}

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