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

请教下problem1019,为何总是wa?

Posted by oracleswt at 2008-09-27 13:13:40
一直wa,不知为何?
测试了以下10个数据:
3587932579
1253871253
12531253
12531
1253165776
23492345
2345267845
23464
234657547
2462298
结果:
82884
43327
3738
128
38823
260
67504
28
3931
1427

代码如下:
#include<iostream>
using namespace std;

int main(void)
{
	int num = 0;
	cin>>num;
	long long *p = new long long[num];
	for(int i2=0; i2<num; i2++)
	{
		cin>>p[i2];
	}


	for(int i=0; i<num; i++)
	{
		long long sum = 0;
		long long j = 1;
		while(sum<p[i])
		{
			sum += j;
			j++;
		}
		
		cout << p[i]-(sum-j+1)<<endl;	
	}
	delete p;
	return 0;
}

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