1074 -- 人见人爱A^B
2015-08-29 17:05
309 查看
人见人爱A^B
Time Limit:1000MS Memory Limit:65536K
Total Submit:109 Accepted:70
Description
求A^B的最后三位数表示的整数。
说明:A^B的含义是“A的B次方”
Input
输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。
Output
对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。
Sample Input
Sample Output
Source
Time Limit:1000MS Memory Limit:65536K
Total Submit:109 Accepted:70
Description
求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
Source
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1074 { class Program { static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { string[] s = sb.Split(); int n = int.Parse(s[0]), m = int.Parse(s[1]); if (n + m == 0) break; int ans = 1; for (int i = 1; i <= m; i++) { ans *= n; ans %= 1000; } Console.WriteLine(ans); } } } }
相关文章推荐
- 【链表】逆序输出
- CSU 1631 Facility Locations
- 边线设置为阴影效果
- C++类中成员变量的初始化
- * Delphi编程时候诡异地出现ORA-00937错误,记录解决它的思路和方法
- 判断鼠标移动事件
- 1073 -- Let the Balloon Rise
- 空字符 空格字符(字符) 空字符串 NULL的区别
- Qt 学习之路 2(3):Hello, world! 笔记
- 原型模式
- iOS 移除地图所有大头针
- 1072 -- Sum Problem
- 1071 -- A+B(8)
- 1070 -- A+B(7)
- HDU1584-A strange lift-最短路(Dijkstra模板题)
- Windows风格的Loading动画Android实现(3)
- 字符串匹配的KMP算法
- POJ_3040 Allowance(greedy)
- 15 腾讯春季软件测试招聘实习 试题
- linux的I/O多路转接select的fd_set数据结构和相应FD_宏的实现分析