当前位置:网站首页>OJ daily exercise - virus proliferation

OJ daily exercise - virus proliferation

2022-06-22 23:33:00 KJ. JK

Problem description :

A certain virus grows into its original form every hour KK times . If at first the virus had SS individual , that HH Hours later, , How many viruses are there ? If the number of viruses reaches or exceeds 20212021 individual , Then the number of output viruses is right 20212021 The mold .

Input
3 It's a positive number K、S、H

Output
1 It's a positive number , Represents the number of viruses . If the number of viruses reaches or exceeds 20212021 individual , Then the number of output viruses is right 20212021 The mold

Examples

Input
2 1 3

Output
8


Java Code :

import java.util.*;          // Viral proliferation 
public class Main {
    
public static void main(String[] args) {
    
   Scanner rd=new Scanner(System.in);
   long k=rd.nextLong();
   long s=rd.nextLong();
   long h=rd.nextLong();
   while(h>0) {
    
	   if((h&1)==1) {
    
		   s=s*k%20212021;
	   }
	   k=k*k%20212021;
	   h>>=1;
   }
   System.out.println(s);
}
}

author :KJ.JK
If the article is helpful to you , Welcome to praise or star, Your support is the greatest encouragement to the author , The shortcomings can be corrected in the comments section , Communication and learning

原网站

版权声明
本文为[KJ. JK]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206222059454342.html