550 - Multiplying by Rotation

来源:互联网 发布:淘宝代销手动下单 编辑:程序博客网 时间:2024/04/20 15:58
#include <iostream>using namespace std;int main(){    long n,x,y,temp,count,i,flag;    while(cin>>n>>x>>y)    {        temp=x;        count=flag=0;        while(1)        {            if(y*temp+flag==x)break;            count++;            i=temp;            temp=(y*temp+flag)%n;            flag=(y*i+flag)/n;        }        cout<<count+1<<endl;    }    return 0;}

原创粉丝点击