摘要: Time Limit: 3000 MS Memory Limit: 65536 K mathpracDescriptionOne lovely afternoon, Bessie's friend Heidi was helping Bessiereview for her upcoming math exam.Heidi presents two integers A (0 <= A <= 45) and B (1 <= B <= 9)to Bessie who must respond with an integer E in the range 1..62 阅读全文
posted @ 2011-04-11 21:59 Matrix海子 阅读(736) 评论(0) 推荐(0) 编辑
摘要: dance2Time Limit: 3000 MS Memory Limit: 65536 K DescriptionThe cow cotillion, a fancy dance every spring, requires the cows(shown as ">") and bulls (shown as "<") to bow to each other duringa dance. Schematically, one properly bowing pair of cattle is shownlike this: " 阅读全文
posted @ 2011-04-11 21:31 Matrix海子 阅读(527) 评论(0) 推荐(0) 编辑
摘要: 求n的阶乘某个因子a的个数,如果n比较小,可以直接算出来,但是如果n很大,此时n!超出了数据的表示范围,这种直接求的方法肯定行不通。其实n!可以表示成统一的方式。n!=(k^m)*(m!)*a 其中k是该因子,m=n/k,a是不含因子k的数的乘积下面推导这个公式n!=n*(n-1)*(n-2)*......3*2*1 =(k*2k*3k.....*mk)*a a是不含因子k的数的乘积,显然m=n/k; =(k^m)*(1*2*3...*m)*a =k^m*m!*a接下来按照相同的方法可以求出m!中含有因子k的个数。因此就可以求除n!中因子k的个数int count(int n,int k){. 阅读全文
posted @ 2011-04-11 21:05 Matrix海子 阅读(1810) 评论(0) 推荐(1) 编辑
摘要: 在处理大数的运算时,一般采用数组去模拟,下面介绍大数的加、减、乘、除四则运算的实现方法。1.加法。 如: Input: 123456789123456789123456789 1 Output:123456789123456789123456790 输入采用字符数组保存,然后将输入存在整形数组里,然后逐位相加即可,同时注意进位处理。#include<stdio.h>#include<string.h>int max(int x,int y){ if(x>y) return x; else return y;}int main(void){ ... 阅读全文
posted @ 2011-04-11 20:34 Matrix海子 阅读(5221) 评论(0) 推荐(0) 编辑