杭电oj_2035——人见人爱A^B(java实现)
2024-10-08 10:32:57
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035
思路:(网上学来的,偏向数学的不咋懂/捂脸)每次乘法的时候都取后三位(可能有些含糊,直接看代码吧,一看就懂)
source code:
package hduoj; import java.util.Scanner; public class hdoj_2035 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true){
int a = sc.nextInt();
int b = sc.nextInt();
if(a==0&&b==0) break;
if(b==0){
System.out.println(1);
continue;
}
a %= 1000;
int r = 1;
for(int i = 0;i<b;++i){
r = r*a%1000;
}
System.out.println(r);
}
}
}
代码已经ac
希望对大家有所帮助
以上
最新文章
- 10月24日上午PHP面向对象
- ubuntu 14.04 下evolution邮箱客户端设置(腾讯企业邮箱)
- DOM--2 创建可重用的对象
- jquery冲突细节
- https证书申请
- AudioServicesPlaySystemSound音频服务—备用
- 利用boost获取时间并格式化
- 排序(6)---------归并排序(C语言实现)
- POJ2115(扩展欧几里得)
- Struts2基础学习(四)&mdash;类型转换器和数据校验
- NSUserDefaults registerDefaults
- python爬虫(七)_urllib2:urlerror和httperror
- Cisco Port-Channel 设置(链路聚合)
- 如何在idea中调试spring bean
- rxjava&;retrofit请求直接返回string
- requirements文件
- 哈希函数(hash函数)
- Python *Mix_w6
- win10上安装keras
- jstl函数的使用