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 200730690105 at 2009-03-24 02:04:37 on Problem 1597 and last updated at 2009-03-24 02:05:35
可以想象成有一个人从起点0处绕着一个圈长为mod个单位“跳步”,每跳一次必须跳step个单位(也就是可不能出现在i*step<pos<(i+1)*step的位置),而至少跳mod次恰好回到起点的话,就是Good Choice,如果在第mod次前就恰好到达起点则为Bad Choice

而我们知道,回到起点把所需的最短时间即是step和mod的最小公倍数,而若为Good Choice,显然最短时间又等于step*mod,由数论的知识gcd(step,mod)=step*mod/(step和mod的最小公倍数)=1

这样为Good Chance的充要条件就是gcd(step,mod)=1

输出
if(gcd(a,b)>1)
{
     printf("%10d%10d    Bad Choice\n\n",a,b);
}
else
{
     printf("%10d%10d    Good Choice\n\n",a,b);
}

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