Bella Ciao solution in C language.- Codechef
Bella Ciao
Problem Code: CHFHEIST
Chef is planning a heist in the reserve bank of Chefland. They are planning to hijack the bank for days and print the money. The initial rate of printing the currency is dollars per day and they increase the production by dollars after every interval of days. For example, after days the rate is dollars per day, and after days the rate is dollars per day, and so on. Output the amount of money they will be able to print in the given period.
Input Format
Output Format
Output For each test case, output in a single line the answer to the problem.
Constraints
Subtask #1 (15 points):
Subtask #2 (85 points): original constraints
Sample Input 1
3
2 1 1 1
3 2 1 1
5 2 1 2
Sample Output 1
3
4
13
Explanation
Test Case :
- On the first day, the rate of production is dollar per day so dollar is printed on the first day.
- On the second day, the rate of production is dollars per day so dollars are printed on the second day.
- The total amount of money printed in days is dollars.
Test Case :
- For the first two days, the rate of production is dollar per day so dollars are printed on the first two days.
- On the third day, the rate of production is dollars per day so dollars are printed on the third day.
- The total amount of money printed in days is dollars.
Test Case :
- For the first two days, the rate of production is dollar per day so dollars are printed on the first two days.
- On the next two days, the rate of production is dollars per day so dollars are printed on the next two days.
- On the last day, the rate of production is dollars per day so dollars are printed on the last day.
- The total amount of money printed in days is dollars.
. . .
Solution in C.
#include <stdio.h> int main(void) { int t; scanf("%d",&t); while(t--){ int a, b; scanf("%d %d",&a,&b); int sum = a+b; if(a>b){ printf("%d %d\n",a,sum); } else{ printf("%d %d\n",b,sum); } } return 0; }
Comments
Post a Comment