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

cin可以过,不会TLE。另,这题的数据貌似有问题。

Posted by bergkamp at 2009-05-02 20:17:50 on Problem 2509
#include <iostream>
using namespace std;
int main()
{
	unsigned long long int n, b, k, sum, t;
	while ( cin>>n>>k )
	{
		sum = 0;
		b = 0;
		while ( n != 0 )
		{
			sum += n;
			t = n;
			n = (t + b) / k;
			b = (t + b) % k;
		}
		cout<<sum<<endl;
	}
	return 1;
}
以上是我的代码。
在Discuss看到lihaosky的AC代码。
这题输入:4 5 应该输出:4
但是lihaosky的代码输出5也AC了。

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