hdu——1061Rightmost Digit(快速幂)
来源:互联网 发布:eclipse不编译java 编辑:程序博客网 时间:2024/06/05 10:44
Rightmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 45812 Accepted Submission(s): 17250
Problem Description
Given a positive integer N, you should output the most right digit of N^N.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the rightmost digit of N^N.
Sample Input
2
3
4
Sample Output
7
6
Hint
In the first case, 3 * 3 * 3 = 27, so the rightmost digit is 7.
In the second case, 4 * 4 * 4 * 4 = 256, so the rightmost digit is 6.
Author
Ignatius.L
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 45812 Accepted Submission(s): 17250
Problem Description
Given a positive integer N, you should output the most right digit of N^N.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the rightmost digit of N^N.
Sample Input
2
3
4
Sample Output
7
6
Hint
In the first case, 3 * 3 * 3 = 27, so the rightmost digit is 7.
In the second case, 4 * 4 * 4 * 4 = 256, so the rightmost digit is 6.
Author
Ignatius.L
Recommend
快速幂直接求就好了 我有一篇快速幂的精简写法的博客可以看看
#include<iostream>#include<string>#include<cmath>using namespace std;long long kk(long long n){long long k=1,m=n;while(m!=0){if(m&1)k*=n%10;m>>=1;n=n*n%10;}return k%10;}int main(){long long n,m;cin>>n;while(n--){cin>>m;cout<<kk(m)<<endl;}return 0;}
0 0
- hdu——1061Rightmost Digit(快速幂)
- hdu 1061 Rightmost Digit(快速幂)
- HDU 1061 Rightmost Digit(快速幂)
- HDU 1061 Rightmost Digit(快速幂)
- HDU 1061 Rightmost Digit (快速幂)
- 【HDU】1061 - Rightmost Digit(快速幂)
- 【hdu 1061】Rightmost Digit(快速幂)
- 快速幂模m HDU——1061 Rightmost Digit
- HDU 1061 Rightmost Digit 【快速求幂】
- HDU 1061-Rightmost Digit(快速幂)
- hdu 1061 Rightmost Digit 快速幂
- Rightmost Digit 【hdu-1061】【快速幂】
- HDU-1061-Rightmost Digit【快速幂】
- hdu 1061 Rightmost Digit(快速幂取余)
- HDU - 1061 - Rightmost Digit (快速幂取模!)
- 快速幂算法(hdu) Rightmost Digit
- hdu 1061 Rightmost Digit(快速幂入门)
- HDU 1061 Rightmost Digit (四则运算求余,快速幂)
- Unix环境高级编程(阅读笔记)----中断的系统调用,自动重启动的函数
- mysql插入数据乱码
- iOS 获取手机的型号,系统版本,软件名称,软件版本
- 第五届山东省ACM Hearthstone II(Dp)
- Java之------单机版书店管理系统(设计思想和设计模式系列八)登录模块
- hdu——1061Rightmost Digit(快速幂)
- HDU 2097 Sky数 (进制转换)
- POJ 1016--Numbers That Count
- 管理及IO重定向
- AngualrJS学习记录-作用域的层级和事件
- JavaScript最佳实践:性能
- Linux下Socket网络编程(C/S)
- Hibernate-没有外键关联的两个表做联合查询
- 在Kaggle手写数字数据集上使用Spark MLlib的朴素贝叶斯模型进行手写数字识别