ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2001. Mathematicians and Berries

a solution
Posted by sotamawhat 5 Mar 2014 19:40
#include <iostream>
using namespace std;
int    main()
{
    int a[3];
    int b[3];
    int sum,m1,m2;
    cin>>a[0]>>b[0];
    if(a[0]<0||b[0]<0||a[0]>10000||b[0]>10000) exit(1);
    sum=a[0]+b[0];

    cin>>a[1]>>b[1];
    if(a[1]<0||b[1]<0||a[1]>10000||b[1]>10000) exit(1);
    if(b[1]>b[0]||(a[1]+b[1]!=sum))exit(1);

    cin>>a[2]>>b[2];
    if(a[2]<0||b[2]<0||a[2]>10000||b[2]>10000) exit(1);
    if(a[2]>a[0]||(a[2]+b[2]!=sum))exit(1);
    m1=a[0]-a[2];
    m2=b[0]-b[1];

    cout<<m1<<' '<<m2;
    return 0;
}

Edited by author 05.03.2014 20:47