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与AC

Posted by Rieman at 2010-12-17 16:42:14 on Problem 2128
n=2时应该只输入一个数,但是if(n>2) cin>>last WA了,光cin>>last却是AC的,奇也怪哉~

#include <iostream>
using namespace std;
const int inf=(int)50001,maxint=(int)10e8;
int main()
{
  int n,mini,pre,now,i,last,a;
  cin>>n;
  mini=maxint;
  cin>>pre;
  for(i=2;i<n-1;i++)
  {
	scanf("%d",&now);
	if(mini>now-pre)
	  mini=now-pre,a=i;
	pre=now;
  }
  if(n>2)  //n=2时应该只输入一个数;
   cin>>last;
  if(n<4)
	cout<<0<<endl;
  else
  {
	cout<<last+mini<<endl;
	printf("%d 1 %d %d\n",a+1,n,a);
  }
  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