| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:我的代码In Reply To:我的代码 Posted by:074100215 at 2009-12-11 18:28:09 > 我考虑的是b,c其中一个肯定不大于2*a,b和c相差越少越好,所以从2*a开始找能整除的,找到就是相差差最少的,也就是和最小的
>
> #include <stdio.h>
> #include <cmath>
>
> int main()
> {
> __int64 a,b,c;
> while(scanf("%I64d",&a)!=EOF)
> {
> b=2*a;
> while((a*b+1)%(b-a)!=0) b--;
> c=(a*b+1)/(b-a);
> c=b+c;
> printf("%I64d\n",c);
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator