Posted by : MCMASTER ACM Saturday, June 25, 2016

Codeforces 478A | Initial Bet



Question:
http://codeforces.com/contest/478/problem/a


Solution:
#include <iostream>
using namespace std;

int main() {


int x1, x2 , x3 , x4 ,x5, tot; 
cin >> x1>> x2 >> x3 >> x4 >>x5; 

// we got the inputs in 

// lets acually grab the sum 

tot = x1 + x2 + x3 + x4 + x5;

if (tot == 0) cout << -1;  // they didnt hv anything to start with 

else if (tot % 5 == 0 ) cout << tot /5 ; // its divisible by 5 we r good and the uniform solution is the correct 

else cout << -1; // else its not divisible by 5 and they didnt hv the same number of coins to start with 


 return 0;
}




Video Explanation: 





If you want us to solve any certain question please leave it down in the comments or send it to us on facebook

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Discover

Top 5 Posts

- Copyright © McMaster ACM Chapter | Protected by CloudFlare