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

我的没这问题,也wa ,为何,代码在下面

Posted by ning at 2005-12-08 22:36:36 on Problem 2509
In Reply To:不是精度不够,是你没考虑到这种情况。 Posted by:tdzl2003 at 2005-07-27 20:58:12
/*pku 2509  Peter's smokes  051210*/
#include<stdio.h>
int main()
{
    long n,nn,k;
    long sum,rst;
    for(;scanf("%ld%ld",&n,&k)!=EOF;)
    {
        for(sum=n,rst=0,nn=n;nn;sum+=(rst+nn)/k,rst=nn%k,nn/=k)
            ;
        printf("%ld\n",sum);
    }
}

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