CPCEJC1-Editorial

PROBLEM LINK:

Practice

Author: Manish Motwani
Tester: Lovish Tater
Editorialist: Manish Motwani

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic Mathematics and Modulo operator

PROBLEM:

We have given the number of people (N) and pizza slices (K). Our task is to find out thar K slices can be distributed in N number of people equally or not.

QUICK EXPLANATION:

Divide number of slices (K) with number of people (N). if it is properly divisible without any remainder then slices can be distributed else not.

EXPLANATION:

In this we will use modulo operator to evaluate the remainder. We will perform K%N operation where K is the number of slices and N is the number of people.

If it results in 0 then slices can be equally distributed else not.

SOLUTIONS:

Setter's Solution
#include <iostream>

using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n,k;
cin>>n>>k;
if(k%n==0)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;
}
return 0;
}

Tester's Solution

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner (System.in);
int t = sc.nextInt();
while(t–>0){
int n = sc.nextInt();
int k = sc.nextInt();
if (k%n==0){
System.out.println(“YES”);
}else{
System.out.println(“NO”);
}
}
}
}

Editorialist's Solution
#include <iostream>

using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n,k;
cin>>n>>k;
if(k%n==0)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;
}
return 0;
}