Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
A disease is spreading through ChefLand!
The disease spreads as follows:
You are given the population of ChefLand NN and a day DD. How many people in ChefLand are infected at the end of day DD?
Subtask 1 (30 points): D≤20D≤20
Subtask 2 (70 points): Original constraints
4
100 3
2000 10
6000 11
10 11
8
1024
3072
10
Test Case 1:
Test Case 2: Following the rules in the statement, it can be seen that at the end of day 1010, the total number of infected people is 10241024.
Test Case 3: Note that starting at day 1111, the number of infected people triples each day, 3×1024=30723×1024=3072.
Test Case 4: At the end of day 33, the number of infected people is 88. Since there are only 1010 people in ChefLand (which is less than 2×8=162×8=16), at the end of day 44 all people in ChefLand are infected and thus the number of infected people is 1010 for all days from day 44 onwards, including day 1111.
#include <stdio.h>
#include <math.h>
int main() {
// Write C code here
int w;
long long int p,d,r;
scanf("%d",&w);
while(w--)
{
scanf("%lld %lld ",&p,&d);
if(d<=10)
{r=pow(2,d);
if(r>p)
r=p;}
else
{ r=pow(2,10);
for(int i=11;i<=d;i++)
{
r=r*3;
if(r>p)
{r=p;
break;
}
}}
printf("%lld",r);
printf("\n");
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t,i,s=1;
cin>>t;
while(t--){
long long int a,b,s=1;
cin>>a>>b;
for(int i=1;i<=b&&s<a;i++){
if(i<11) s*=2;
else s*=3;
}
if(s>=a) s=a;
cout<<s<<endl;
}
return 0;
}
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
{
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-- != 0){
long n = s.nextLong();
long d = s.nextLong();
long sum = 1;
for(long i = 1; i<=d; i++){
if(i<=10){
sum = sum * 2;
if(sum > n){
sum = n;
break;
}
}
else
{
sum = sum * 3;
if(sum > n)
{
sum = n;
break;
}
}
}
System.out.println(sum);
}
s.close();
}
}
try:
t = int(input())
for i in range(t):
n,d = map(int,input().split(" "))
# print(n,d)
# print(type(n))
if d<=10:
ans = 2**d
if ans <= n:
print(ans)
else:
print(n)
elif d>10:
ans = 1024
if ans <= n:
if d>20:
print(n)
else:
ans = ans*(3**(d-10))
if ans <= n:
print(ans)
else:
print(n)
# print(ans)
# if ans <= n:
# print(ans)
# else:
# print(n)
else:
print(n)
except: pass
In our experience, we suggest you solve this Covid Spread CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Covid Spread Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Covid Spread CodeChef Solution.
I hope this Covid Spread CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More CodeChef Solutions >>
Olympics Ranking CodeChef Solution
Problem Difficulties CodeChef Solution
Chef and Bulb Invention CodeChef Solution