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

wa求助各路大神

Posted by liugan160 at 2014-10-28 19:17:43 on Problem 2115
#include<iostream>
#include<cmath>
using namespace std;
long long x,y,z,m,n,k;
double f,g;
int main()
{
    long long a,b,c,d,e;
    while(cin>>a>>b>>c>>k && a && b && c && k)
    {
        x=b-a;
        f=k;
        f=pow(2,f);
        y=f;
        if(x<0) x=x+y;
        if(x%y==0) {cout<<0<<endl; continue;}
        if((x&(-x))<(c&(-c)))
        if((x&(-x))<y){cout<<"FOREVER"<<endl; continue;}
        z=y%c;
        m=x%c;
        d=0;
        while((d*z+m)%c) d++;
        cout<<(d*y+x)/c<<endl;
    }
    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