上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 27 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1407刚开始用暴力,但有优化,结果一直都是TLE,不知道是不是hdoj上面有什么改动没有,后来用了打表的方法,125ms过了View Code 1 #include <stdio.h> 2 #include <math.h> 3 4 int main() 5 { 6 int x, y, z, num, flag; 7 int a[101]; 8 for(x = 1; x < 101; x++) { 9 a[x] = x*x... 阅读全文
posted @ 2013-04-17 22:09 执着追求的IT小小鸟 阅读(157) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1339把2的n次方打表,然后将输入的n依次除以这些数,知道可以整除,输出可以整除的元素的位置的排列,极为p,而n除以这个2^p就是o了逐个查找View Code 1 #include<stdio.h> 2 int main() 3 { 4 int a[100],i,size,n,d,o; 5 a[0]=1; 6 for(i=1;;i++) 7 { 8 if(a[i-1]>1000000) 9 {10 size=i-1;11 ... 阅读全文
posted @ 2013-04-17 21:38 执着追求的IT小小鸟 阅读(155) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1321这题只需反过来输出就可以了,我这里的代码是改自UVA的483View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 void shuchu(char *s,int *i)//当不是空格是倒序输出 5 { 6 char temp[100]; 7 int j=0,k; 8 while((*s)!=32&&(*s)!='\0') 9 {10 temp[ 阅读全文
posted @ 2013-04-17 21:04 执着追求的IT小小鸟 阅读(208) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2114先用打表,可是一直错误,后来发现有个什么数学公式,然后才对了打表View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 __int64 n,sum; 6 int i,a[10001]; 7 a[0]=0; 8 a[1]=1; 9 for(i=2;i<=9999;i++)10 a[i]=((i%10000)*(i%10000)*(i%10000)+a[i-1])%100... 阅读全文
posted @ 2013-04-17 12:48 执着追求的IT小小鸟 阅读(134) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2095这题巧妙的运用了位运算的方法,同一个数位运算两次,化为0;多个数的话就留下了出现次数是奇数的那个数View Code 1 #include<stdio.h> 2 int main() 3 { 4 int i,k,n,s; 5 while(scanf("%d",&n),n) 6 { 7 s=0; 8 for(i=0;i<n;i++) 9 {10 scanf("%d",&k);11 s^=k;12 }13 printf("% 阅读全文
posted @ 2013-04-15 22:22 执着追求的IT小小鸟 阅读(153) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2070斐波那契数列,关键在于类型的定义you can use 64bit integer: __int64,printf("%I64d\n");View Code 1 #include<stdio.h> 2 int main() 3 { 4 __int64 i,f[100]; 5 int n; 6 f[0]=0; 7 f[1]=1; 8 for(i=2;i<=50;i++) 9 f[i]=f[i-1]+f[i-2];10 while(scanf("... 阅读全文
posted @ 2013-04-15 19:51 执着追求的IT小小鸟 阅读(180) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2022存入,逐个比较即可,当然边存入边比较会更快View Code 1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int n,m,i,j,x,y,s; 6 int a[100][100]; 7 while(scanf("%d%d",&n,&m)!=EOF) 8 { 9 for(i=0;i<n;i++)10 for(j=0;j<m;j++)11 sc... 阅读全文
posted @ 2013-04-13 21:09 执着追求的IT小小鸟 阅读(214) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2015先把不属于多出来的那些数的求和并输出,然后再去处理多出来的那几个View Code 1 #include<stdio.h> 2 int main() 3 { 4 int n,m,k,i,sum,j; 5 int a[101]; 6 a[1]=2; 7 for(i=2;i<101;i++) 8 a[i]=a[i-1]+2; 9 while(scanf("%d%d",&n,&m)!=EOF)10 {11 k=n/m;12 for... 阅读全文
posted @ 2013-04-13 18:13 执着追求的IT小小鸟 阅读(180) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2018写出前面几个年份的数量,就是一个仿斐波那契数列View Code 1 #include<stdio.h> 2 int main() 3 { 4 int ans[55],i,n; 5 for(i=0;i<4;i++) 6 ans[i]=i+1; 7 for(i=4;i<55;i++) 8 { 9 ans[i]=ans[i-1]+ans[i-3];//这题跟斐波那契数列,兔子问题类似,f[n]=f[n-1]+f[n-3] 10 }//预先打表 11 while(... 阅读全文
posted @ 2013-04-13 18:03 执着追求的IT小小鸟 阅读(143) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1170这题麻烦在于每次输入之后的接收回车,还有对结果是否是整数的判断,The result should be rounded to 2 decimal places If and only if it is not an integer.View Code #include<stdio.h>#include<conio.h>int main(){ int a,b,t,ans1; double ans2; char c,s[20]; scanf("%d",& 阅读全文
posted @ 2013-04-12 11:57 执着追求的IT小小鸟 阅读(190) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 27 下一页