[Login|Register]
New post

Show post

Search forum

Read topic
超时 2015-10-01 19:17:04 cmer
心累
#include<stdio.h>
int main(){
    long int m,a,b,i,x;
    while(scanf("%ld %ld %ld",&m,&a,&b)!=EOF){
        if(m==-1&&a==-1&&b==-1) break;
        x=b;
        for(i=1;;i++){
            if(x==m){break;}
            x=x*a+b;
            if(x>9999677) x=x%999967;
        }
        printf("%ld\n",i);
        }

   }
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.9ms with 1 query(s).