Setter: Rahul Kumar
Tester: Aniket Kumar
Editorialist: Rahul Kumar
DIFFICULTY:
CAKEWALK
PROBLEM:
Chef is has N chocolates. He wants it to be distributed equally with his K friends.
Print how many chocolates are left after distribution.
EXPLANATION:
We can distribute N/K chocolates to all. The remaining chocolate is the remainder when N is divided with K.
TIME COMPLEXITY:
O(1)
SOLUTION:
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define vi vector<int>
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
int32_t main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
fio
w(t)
{
int n,k;
cin>>n>>k;
cout<<n%k<<"\n";
}
}
Please comment below if you have any questions, alternate solutions, or suggestions.