| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪里有错,runtime error#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator