NOTEBOOK - Editorial

PROBLEM LINK:

Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4

Setter: Utkarsh Gupta
Tester: Abhinav Sharma
Editorialist: Kanhaiya Mohan

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

You know that 1 kg of pulp can be used to make 1000 pages and 1 notebook consists of 100 pages.

Suppose a notebook factory receives N kg of pulp, how many notebooks can be made from that?

EXPLANATION:

We are given that 1 notebook contains 100 pages.
Thus, from 1000 pages, we can make \frac{1000}{10} = 10 notebooks.

We are also given that 1 kg of pulp can make 1000 pages. Since 1000 pages can make 10 notebooks, we can make 10 notebooks from 1 kg of pulp.

Conclusion: From 1 kg pulp, we can make 10 notebooks. Thus, from N kg pulp, we can make 10 \cdot N notebooks.

TIME COMPLEXITY:

The time complexity is O(1) per test case.

SOLUTION:

Tester's Solution
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    cin >> T;
    while(T--){
    
        int n;
        cin>>n;

        cout<<10*n<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}
Editorialist's Solution
#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    cout<<10*n<<endl;
	}
	return 0;
}