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

代数学少了吧? 会求模逆就会做~ ^_^

Posted by speedup at 2010-10-23 18:53:48 on Problem 1006
下面的代码仅供参考:
#include<iostream>
using namespace std;

int Solve(int k,int p)
{
	int m;
	for(m=1;m<p && m*k%p!=1;m++);
	return m;
}

int main()
{
	int p,e,i,d,c=0,val,pS,eS,iS;
	pS=Solve((28*33)%23,23)*28*33;
	eS=Solve((23*33)%28,28)*23*33;
	iS=Solve((23*28)%33,33)*23*28;
	while(cin>>p>>e>>i>>d && p!=-1)
	{
		p=(23+(d-p)%23)%23;
		e=(28+(d-e)%28)%28;
		i=(33+(d-i)%33)%33;
		val=(p*pS+e*eS+i*iS)%21252;
		val=21252-val;
		cout<<"Case "<<++c<<": the next triple peak occurs in "<<val<<" days."<<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