摘要:
Problem Description求A^B的最后三位数表示的整数。说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1using namespace std;int main(){ int x,y,i; int m=1; while(cin>>x>>y&&x&&y) { for(i=0;i<y;i++) { m=m*x; m=m%1000;//因为只关心最后三位,所以每次都把得到的结果取最后三位与下一个m相乘 } ... 阅读全文
posted @ 2013-05-21 15:07
同学少年
阅读(295)
评论(0)
推荐(0)
摘要:
题目描述Saya and Kudo go shopping together.You can assume the street as a straight line, while the shops are some points on the line.They park their car at the leftmost shop, visit all the shops from left to right, and go back to their car.Your task is to calculate the length of their route.输入The input 阅读全文
posted @ 2013-05-21 14:54
同学少年
阅读(289)
评论(0)
推荐(0)
摘要:
Problem DescriptionWe all love recursion! Don't we?Consider a three-parameter recursive function w(a, b, c):if a 20 or b > 20 or c > 20, then w(a, b, c) returns:w(20, 20, 20)if a using namespace std;int main(){ int w[21][21][21];//要比20大 int i,j,k; for(i=0;i>a>>b>>c&& 阅读全文
posted @ 2013-05-21 14:37
同学少年
阅读(231)
评论(0)
推荐(0)
摘要:
问题描述:输入多组数据,输出其二进制的形式,以输入0 结束程序。解法:循环。用一个数组来存放每次运算的余数,每次运算指的是被除数 除以 2 ,每得到一个余数就放到数组里面,一直运算知道被除数等于0为止,输出二进制要从数组里逆序输出。代码:#include using namespace std;int a[100];//数组用来存放余数int main(){ int beichushu,yushu,i=1; while(cin>>beichushu&&beichushu!=0)//多次输入,以0结束程序 { while (beichushu!=0) ... 阅读全文
posted @ 2013-05-21 14:20
同学少年
阅读(220)
评论(0)
推荐(0)

浙公网安备 33010602011771号