click below for solution

Wednesday, 26 January 2022

Average of Three solution|Codesheff starter 23 for div 2 solution

It is Chef's birthday. You know that Chef's favourite number is X. You also know that Chef loves averages. Therefore you decide it's best to gift Chef 3 integers A1,A2,A3, such that:

  • The mean of A1,A2 and A3 is X.
  • 1A1,A2,A31000.
  • A1,A2 and A3 are distinct.

Output any suitable A1,A2 and A3 which you could gift to Chef.

As a reminder, the mean of three numbers P,Q,R is defined as: mean(P,Q,R)=P+Q+R3.

For example, mean(2,3,5)=2+3+53=103=3.333¯mean(2,2,5)=2+2+53=93=3.

Input Format

  • The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains one integer X — Chef's favourite number.

Output Format

For each test case, one line containing 3 space-separated integers — A1,A2, and A3, which satisfy the given conditions. If there are multiple possible answers you may output any of them.

It can be shown that an answer always exists, under the given constraints.

Constraints

  • 1T100
  • 2X100

Sample Input 1 

3
3
5
5

Sample Output 1 

1 3 5
1 6 8
3 5 7

Explanation

Test Case 1: mean(1,3,5)=1+3+53=93=3

Test Case 2: mean(1,6,8sdf)=1+6+83=153=5

Test Case 3: 


solution:

#include <iostream>

using namespace std;

int main()

{

    int t;

    cin>>t;

    while(t--){

       int a;

       cin>>a;

        cout<<a-1<<" "<<a<<" "<<a+1<<endl;         

      }

   

    return 0;

}



No comments:

Post a Comment