Codechef Problems: Vacation Excitement (VACAEX)

 Problem Statement: 


Solution: 

Given, 
    X: day of March when vacation begins 
    Y: Excitement Level on march 1 

condition: Excitement level increases by 1 for everyday it passes till vacation 

To find: Excitement level on the day vacation begins 

Since excitement level of chef on, 
day 1 = Y 
day 2 = Y + 1 
day 3 = Y + 2 

... 

day X = Y + (X - 1) 

hence, the answer of the problem will be (X + Y - 1) 

Code Solution: 

#include <bits/stdc++.h>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    cout << x + y - 1 << endl;
    return 0;
}

Comments

Popular posts from this blog

Codechef Problems: Triangles (TRIANGLE7)

Codechef Problems: Assignment Due (P1_175)

Codechef Problems : Happy New Year! (NEWYEAR)