CodechefMay 07, 2025

The Last Levels

Hazrat Ali

Codechef

There are XX levels remaining in the game, and each level takes Chef YY minutes to complete. To protect against eye strain, Chef also decides that every time he completes 33 levels, he will take a ZZ minute break from playing. Note that there is no need to take this break if the game has been completed.

How much time (in minutes) will it take Chef to complete the game?

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • The first and only line of input will contain three space-separated integers XXYY, and ZZ.

Output Format

For each test case, output on a new line the answer — the length of Chef's gaming session.

Constraints

  • 1≤T≤100
  • 1≤X≤100
  • 5≤Y≤100
  • 5≤Z≤15

Sample 1:

Input
 
4
2 12 10
3 12 10
7 20 8
24 45 15
 
Output
 
24
36
156
1185


Solution

#include <stdio.h>

int main(void)
{

    int m,temp=0,div=0;
    scanf("%d",&m);
    while(m--)
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(a <= 3)
            printf("%d\n",a*b);
        else
        {
            int sum = (a*b);
            div = a/3;
            temp = a - div*3;
            if(temp == 0)
            {
                printf("%d\n",(div-1)*c + sum);
            }
            else printf("%d\n",div*c+sum);
        }
    }
    return 0;
}




 

Comments