博文
求n!中末尾含有多少个0(2006-08-28 12:38:00)
摘要:求n!中末尾含有多少个0int count(int n){ int sum=0; int x=0; for(;n>0;) { sum+=(n%5)*x; n/=5; x=x*5+1; } return sum;}......
第38次编程比赛第一题的一个超快速算法(2006-08-21 10:55:00)
摘要: 第38次编程比赛第一题的一个超快速算法 这个算法计算速度超快,我只是按设计的算法粗糙的实现了一下,当N=4000000000(四十亿)的时候,计算时间不超过100毫秒, 我没有具体测这个时间,只是一运行,马上就会出结果,无需等待. ////////////////////////////////////////////////////// 原题目 在N以内(小于等于N)找出一个数,要求: 1.这个数的约数的个数达到最大, 2.如果有好几个数满足条件1,仅取最小的那个数 说明: 1) 1<N<=2^32-1,每个N的时限是1000ms。内存限制256M,注意使用适当数据类型,以免溢出。 函数原型: // n: 范围 // result:结果,存放符合条件的那个数 // count:存入存放符合条件的那个数的约数的个数 // arr:存放那个数的所有约数,按照从小到大的顺序 void Search(unsigned long n, unsigned long *result,int *count,unsigned long arr[]); 例: n=100, 则 result=60, 在100以内,60和90的约数个数同为12个,达到这个范围内所有整数中,其约数个数的最大值,但60比90小, 所有正确答案为60。60共有12个约数:1,2,3,4,5,6,10.12.15.20.30,60.所以count应该存入12,从arr[0]开始, 应该依次写入1,2,3,4,5,6,10.12.15.20.30,60。  ......
TC2.0环境下的贪食蛇!!(2004-12-24 17:15:00)
摘要:#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<malloc.h>
#include<math.h>
/**********/
#define PATH "D:\\学习\\turboc2" /*你的TC安装目录*/
#define BK 7
#define DC 8
#define LC 15
#define P1 1
#define P2 4
#define X 41
#define Y 41
#define M 22
#define SX 490
#define SY1 50
#define SY2 107
#define HJ 32
#define TX 410
#define TY 160
/************/
int newmap[M][M] ={
{1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1},
{1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1},
{1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1},
 ......
