hdu1097 A hard puzzle

    xiaoxiao2026-05-27  0

    A hard puzzle

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39806    Accepted Submission(s): 14338 Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin. this puzzle describes that: gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.   Input There are mutiple test cases. Each test cases consists of two numbers a and b(0<a,b<=2^30)   Output For each test case, you should output the a^b's last digit number.   Sample Input 7 66 8 800   Sample Output 9 6 快速幂 #include <iostream> #include <cstdio> #include <cstring> #define mod 999999999 //快速米 using namespace std; void pow(int n,int p) { int s=1; while(p) { if(p&1) { s=s*n%10; } n=n*n%10; p>>=1; } cout<<s%10<<endl; } int main() { int a,b; while(cin>>a>>b) { pow(a,b); } return 0; } Author
    转载请注明原文地址: https://ju.6miu.com/read-1310132.html
    最新回复(0)