 # VALENTINE - Editorial

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

Cakewalk

None

# PROBLEM:

Chef has a total of X Rs and one chocolate costs Y Rs. What is the maximum number of chocolates Chef can buy.

# EXPLANATION:

We are given that one chocolate costs Y rupees. Thus, in X rupees, we can buy ⌊\frac{X}{Y}⌋ chocolates.
Here, ⌊N⌋ is floor(N) which represents the greatest integer not greater than N.
Note that in languages like C++ and Java, a floating point number is automatically rounded down to the nearest integer.

Examples
• X = 7, Y = 2: We know that 1 chocolate costs 2 rupees. Then, from 7 rupees, we can buy ⌊\frac{7}{2}⌋ = ⌊3.5⌋ = 3 chocolates.
• X = 15, Y = 3: Single chocolate costs 3 rupees. Then, from 15 rupees, we can buy ⌊\frac{15}{3}⌋ = ⌊5⌋ = 5 chocolates.

# 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);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r" , stdin);
freopen("output.txt", "w" , stdout);
#endif
int T=1;
cin >> T;
while(T--){

int x,y;
cin>>x>>y;

cout<<x/y<<'\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 x, y;
cin>>x>>y;
cout<<(x/y)<<endl;
}
return 0;
}