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

避免中间过程超long long的方法

Posted by chinabest at 2014-01-14 19:56:30 on Problem 2891
关键就在于求出方程的解有可能很大很大,要马上模掉。
code:
                z=(r2-r1)/rnt*z;
                I64 tmp=m2/rnt;
                z=((z % tmp) + tmp) % tmp;
                r1=m1*z+r1;
                m1=m1/rnt*m2;
                r1%=m1;

如果没有第三行的话,在第4行就会越界。加油吧————各位。

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