| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
why wa?#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int i,j,l;
int k; // Numbers.
double a[30]; // Each number is in the range 0 < a[i] < 10^7.
double subtrahend;
double a1,a2,a3;
int flag;
cin >> k;
while(k > 0)
{
flag = 0;
cin >> a[0];
if(k == 1)
{
cout << "NO" << endl;
}
else
{
for (i=1; i<k; i++)
{
cin >> a[i];
}
for(i=0; i<k-1; i++)
{
for(j=i+1; j<k; j++)
{
subtrahend = fabs(a[i] - a[j]);
if(subtrahend < 1e-6)
{
cout << "YES" << endl;
flag = 1;
break;
}
else
{
for(l=0; l<k; l++)
{
if(l!=i && l!=j)
{
if(subtrahend-a[l] < 1e-6)
{
a1 = a[i];
a2 = a[j];
a3 = a[l];
if(a1 > a2)
{
a1 = a[j];
a2 = a[i];
}
if(a2 > a3)
{
a3 = a2;
a2 = a[l];
}
if(a3-a1-a2 < 1e-6)
{
cout << "YES" << endl;
flag = 1;
break;
}
}
}
}
}
if(flag > 0) break;
}
if(flag > 0) break;
}
if(flag == 0) cout << "NO" << endl;
}
cin >> k;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator