Question Name:STUDIOUS LITTLE JHOOL

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        if(n<10){
            cout << "-1" << endl;
            continue;
        }
        if(n%12==0){
            cout << n/12 << endl;
            continue;
        }
        int cnt = 0,flag=0;
        while(n>=0){
            n-=10;
            cnt++;
            if(n%12==0){
                cout << cnt+n/12 << endl;
                flag=1;
                break;
            }
        }
        if(flag==0){
            if(n==0)
                cout << cnt << endl;
            else
                cout << -1 << endl;
        }
    }
    return 0;
}
  • Problem Description
    Yes, you read it right – Little Jhool is back, but no, he’s not over his break up, still. And he’s sad, broken and depressed; thus, he decided to visit a psychologist. She tells him to think about his pleasant memories of childhood, and stay busy so as to not miss his ex-girlfriend.

    She asks him about his favorite memories from childhood, and being the genius Mathematician Little Jhool is, he remembered that solving Mathematics problem given to him by his teacher was his favorite memory.

    He had two types of notebooks, when he was a kid. 10 problems could be solved in one page, in the first notebook. 12 problems could be solved in one page, in the second notebook.
    Little Jhool remembered how in order to maintain symmetry, if he was given with n problems in total to solve, he tore out pages from both notebooks, so no space was wasted. EVER!

    But, now he’s unable to solve his own problem because of his depression, and for the exercise of the week, he has to answer the queries asked by his psychologist.

    Given n number of questions, print the minimum number of pages he needs to tear out from the combination of both the notebooks, so that no space is wasted.

    Input Format:

    The first line will contain t – number of test cases.
    The second will contain an integer n – number of questions.

    Output Format:

    Corresponding to the input, print the minimum number of pages Little Jhool needs to tear out from the combination of both the notebooks. If it is NOT possible, print “1”.

    Constraints:
    1<=t<=100 
    1<=n<=113
  • Test Case 1
    Input (stdin)2
    23
    32
    Expected Output-1
    3
  • Test Case 2
    Input (stdin)20
    27
    69
    81
    41
    43
    22
    28
    60
    51
    13
    58
    64
    46
    30
    78
    45
    99
    71
    98
    83
    Expected Output-1
    -1
    -1
    -1
    -1
    2
    -1
    5
    -1
    -1
    5
    6
    4
    3
    7
    -1
    -1
    -1
    9
    -1

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro