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

try this function~

Posted by majia5 at 2008-10-27 22:56:26 on Problem 3696 and last updated at 2008-10-27 22:57:54
In Reply To:关于这道题,请教大侠一个问题? Posted by:HCman at 2008-10-27 20:02:36
typedef unsigned long long llong;
llong pro(llong x,llong y,llong n)
{
	llong ret=0,tmp=x%n;
	for(;y;y>>=1)
		{
			if(y&0x1)
				if((ret+=tmp)>n)ret-=n;
			if((tmp<<=1)>n)tmp-=n;
		}
	return ret;
}
用这个来做乘法运算~计算(x*y)%n
PS.枚举直接dfs就好了,就是把它的素因子拿去乘~

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