#2035:人见人爱A^B】的更多相关文章

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2035 人见人爱A^B Description 求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方” Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理. Output 对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行. Sample Input 2 312…
人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 27711    Accepted Submission(s): 18946 Problem Description 求A^B的最后三位数表示的整数. 说明:A^B的含义是"A的B次方"   Input 输入数据包含多个测试实例,每个实例占一行,由两个正整 数A和…
人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 27954    Accepted Submission(s): 19117 Problem Description 求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方”   Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A…
人见人爱A^B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 53859    Accepted Submission(s): 35959 Problem Description 求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方”   Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035 解题思路:这一题数据不大,可以用同余来做,也可以用快速幂来做 反思:定义成 #include<stdio.h> int quick_mod(int a,int b,int m) { int ans=1; while(b) { if(b&1) { ans=(ans*a)%m; b--; } b=b>>1; a=a*a%m; } return ans; } int main(…
题意:求A的B次方的后三位数字 思路1:常规求幂,直接取余求解 代码: #include<iostream> #include<cstdio> using namespace std; int main(){ int a,b; int ans; while(~scanf("%d%d",&a,&b)){ &&b==) break; a=a%;//底数取余 ans=; while(b--){ ans=(ans*a)%;//结果取余 }…
#include<stdio.h> int main() { int a,b; int s; int i; while(scanf("%d %d",&a,&b)!=EOF&&a&&b) { s=1; for(i=1;i<=b;i++) { s*=a%1000; s=s%1000; } printf("%d\n",s%1000); } }…
同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+dy(mod m) -同余式可以相加 ac = bd(mod m) -同余式可以相乘 a^n = b^n(mod m) f(a) = f(b)(mod m) if a = b(mod m) and d|m then a = b(mod d) eg: 320 = 20(mod 100) and d =…
2028  Lowest Common Multiple Plus #include<stdio.h> int gcd(int a,int b){ int temp,temp1; if(a<b){ temp = a; a = b; b = temp; } ){ temp1 = a%b; a = b; b = temp1; } return b; } int main(){ int n,s,i; long long k; while(scanf("%d",&n)…
求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方”   Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理.   Output 对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行.   Sample Input 2 3 12 6 6789 10000 0 0   Sample Output 8 984 1 2035#include<stdio.h&…