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

Re:试了从1到10000,和另外一个AC的程序输出一模一样,二进制比较的,怎么我的总是WA??

Posted by gaoshan at 2009-08-15 16:33:43 on Problem 2000
In Reply To:试了从1到10000,和另外一个AC的程序输出一模一样,二进制比较的,怎么我的总是WA?? Posted by:ivorstar at 2009-02-16 22:24:38
> 总是WA,谁给看看哪错了?
> #include <iostream>
> 
> using namespace std;
> 
> int calcCoins(int days);
> 
> int main()
> {
> 	int days;
> 
> 	while(cin >> days && days)
> 	{
> 		cout << days << " " << calcCoins(days) << endl;
> 	}
> }
> 
> int calcCoins(int days)
> {
> 	int i, sum = 0, r = 0;
> 	for(i = 1; i <= days; i++)
> 	{
> 		sum = i * (i + 1) / 2;
> 		if(sum > days)
> 			break;
> 	}
> 
> 	for(int j = 1; j < i; j++)
> 	{
> 		r += j * j;
> 	}
> 
> 	r += i * (days + i - sum);
> 
> 	return r;
> }

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