求n^n的个位 Sample Input 2 3 4 Sample Output 7 6 直接快速幂了,注意要用long long #include<cstdio> long long quick_mod(long long a,long long b,long long m) { ; while (b) { ) { ans = (ans * a) % m; b--; } b/=; a = a * a% m; } return ans; } int main() { int t,n; scan…
#include<stdio.h> #include<string.h> int a[10]; int main() { int T,n,i,k,temp,b,t; scanf("%d",&T); while(T--) { memset(a,0,sizeof(a)); scanf("%d",&n); t = n; n %= 10; if(n==1||n==0) { printf("%d\n",n); con…
求大量N^N的值最右边的数字,即最低位. 它将能够解决一个简单二分法. 只是要注意溢出,只要把N % 10之后.我不会溢出,代替使用的long long. #include <stdio.h> int rightMost(int n, int N) { if (n == 0) return 1; int t = rightMost(n / 2, N); t = t * t % 10;; if (n % 2) t *= N; return t % 10; } int main() { int T…
Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 55522 Accepted Submission(s): 20987 Problem Description Given a positive integer N, you should output the most right digit of N…
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…