Chef and Keyboard CHEFKEY
PROBLEM :- CHEFKEY SUBMIT IN PRACTICE- SUBMIT
DIFFICULTY- very easy
EXPLANATION-
This is one of the easy problem.
Assume here that you are given a rectangle of some dimension say n × m.
all you have to do is to find the number of rectangles
which has integral dimension and have area c.
So this problem can be solve in O(min(n,m))
Assume min and max as two variables.
Set min and max by comparing n and m.
Run a loop from 1 to min (one integer factor of c)
Check if c/i is factor of c.
CODE- C++ (for C replace cin by scanf and cout by printf)
#include<iostream>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
int n,m;
cin>>n>>m;
int c;
cin>>c;
//assuming n as min value and m as maximum value
int min=n,max=m;
//setting min and max
if(min>max) {
min=m;
max=n;
}
int count=0;
//running a loop from 1 to minimum value
for(int i=1;i<=min;i++)
{
int x = c/i //dividing c by i i.e. assuming i as a factor of c
//here verifying if x is integer or not if yes than we are checking if it is less than max or not
//if it is less than max then increasing count by 1
if(x*i==c)
if(x<=max)
count++;
}
//printing count
cout<<count<<endl;
}
}
#happy_coding #codebrace
If you find something wrong or have any question about the solution then comment down below, you can also contact us using contact form