A. In Search of an Easy Problem
As the name suggest it is an easy problem all what is needed is to take a string s as input and print Mohamed Salah
#include<iostream>
using namespace std;
int main()
{
string str;cin>>str;
cout<<"Mohamed Salah";
}
C. P vs. NP
If $$$a$$$%$$$b=0$$$ ($$$a$$$ is divisible by $$$b$$$), just print $$$0$$$. Otherwise, we need exactly $$$b − a$$$%$$$b$$$ moves to make zero remainder of $$$a$$$ modulo $$$b$$$. % is the modulo operation.
#include<iostream>
using namespace std;
int main(){
int t = 1; cin >> t;
while(t--){
int a,b;
cin >> a >> b;
if(!(a%b)) cout<<"0\n";
else cout<<b-(a%b)<<"\n";
}
return 0;
}
F. N and T
In this problem we want to find a number that is divisible by t and has n digits. But we found a series of problems:
n can be 100 -> there is no data type that handles such a big number (long long take up to pow(2,64))
How can I easily get a number divisible by t
The answer is t itself and
what about multiplying the number by 10 until I get the desired length? why 10: multiplying by 10 will keep the divisibility state (2x10 is divisible by 2 and 2x10x10 is still divisible by 2....)
so the answer will be the t multiplied by 10 until I reach the desired length. -> problem 2 solved
multiplying by 10 means adding 0 to the end of the number (2x10 = 20, 330x10 = 3300)
so we can print the t followed by zeros -> problem 1 solved
but when I will print -1? the answer is if the number of digits in t is less than n as the smallest number is divisble by t is t itself
#include <iostream>
#include <vector>
using namespace std ;
int32_t main() {
int n,t;cin>>n>>t;
if(t == 10 && n== 1){
cout<<"-1";
}else{
cout<<t;
n--;
if(t == 10)n--;
for (int i = 0; i < n; ++i) {
cout<<"0";
}
}
}
J. Salma Has Cakes and You Don't!
Not finished yet
#include<bits/stdc++.h>
using namespace std;
void fast(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
int main()
{
fast();
int n, m;
cin >> n >> m;
int arr[n];
for(int i = 0; i<n; i++){
cin >> arr[i];
}
int freq[100005]={0},pref[n+1];
pref[n] = 0;
for(int i = n-1; i>=0; i--){
if(freq[arr[i]] == 0)
pref[i] = pref[i+1] + 1;
else
pref[i] = pref[i+1];
freq[arr[i]]++;
}
int q;
while(m--){
cin >> q;
cout<<pref[q-1]<<"\n";
}
return 0;
}