Codeforces 1230A A. Dawid and Bags of Candies SOlution
Solve in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE
///Islamic University,Bangladesh
#include<bits/stdc++.h>
using namespace std;
int main()
{
int ar[10000],s1=0,i,s2=0;
for(i=0; i<4; i++)
{
cin>>ar[i];
}
if(ar[0]+ar[1]==ar[2]+ar[3])
cout<<"YES"<<endl;
else if(ar[0]+ar[2]==ar[1]+ar[3])
cout<<"YES"<<endl;
else if(ar[0]+ar[3]==ar[1]+ar[2])
cout<<"YES"<<endl;
else if(ar[0]+ar[1]+ar[2]==ar[3])
cout<<"YES"<<endl;
else if(ar[0]+ar[1]+ar[3]==ar[2])
cout<<"YES"<<endl;
else if(ar[0]+ar[3]+ar[2]==ar[1])
cout<<"YES"<<endl;
else if(ar[3]+ar[1]+ar[2]==ar[0])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE
///Islamic University,Bangladesh
#include<bits/stdc++.h>
using namespace std;
int main()
{
int ar[10000],s1=0,i,s2=0;
for(i=0; i<4; i++)
{
cin>>ar[i];
}
if(ar[0]+ar[1]==ar[2]+ar[3])
cout<<"YES"<<endl;
else if(ar[0]+ar[2]==ar[1]+ar[3])
cout<<"YES"<<endl;
else if(ar[0]+ar[3]==ar[1]+ar[2])
cout<<"YES"<<endl;
else if(ar[0]+ar[1]+ar[2]==ar[3])
cout<<"YES"<<endl;
else if(ar[0]+ar[1]+ar[3]==ar[2])
cout<<"YES"<<endl;
else if(ar[0]+ar[3]+ar[2]==ar[1])
cout<<"YES"<<endl;
else if(ar[3]+ar[1]+ar[2]==ar[0])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
No comments