上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 27 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2028逐个用辗转相除法算出最小公倍数,直至结束,但是因为中间结果有可能超过32位,所以必须相除后乘,只是这里不懂为什么改了long long还是错掉r=a%b; while(r) { a=b; b=r; r=a%b; }结果b是最大公约数,最小公倍数就是原来ab的积除以bView Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 int s[100000]; 4 int pro(int a,int b)... 阅读全文
posted @ 2013-04-06 22:03 执着追求的IT小小鸟 阅读(199) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2089这题感觉应该用打表的方法,否则会超时,刚开始时用把数字放到字符串里,然后依次判断,因为查询的方向错了,wa,,,,后来用数字对10和100取模然后跟4和62比较,会更简洁。把所有判断好的数按顺序在数字(或字符串)中做好标记,然后可以在输入后直接计算结果View Code 1 #include<stdio.h> 2 int jili(int n) 3 { 4 char s[500]; 5 int i=0,j; 6 while(n) 7 { 8 if(n%10==4||n%100==62)//. 阅读全文
posted @ 2013-04-02 22:11 执着追求的IT小小鸟 阅读(210) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1017输入俩数n,m,计算满足(a^2+b^2 +m)/(ab) is an integer.的(a,b)对,并按格式输入结果在判断结果是否为整数时,把除号换成取模,然后跟0相比较,就可以知道是否为整数View Code 1 #include<stdio.h> 2 int main() 3 { 4 int n,m,a,b,t,k,i,ca; 5 scanf("%d",&t); 6 for(i=1;i<=t;i++) 7 { 8 ca=1; 9 while(scan 阅读全文
posted @ 2013-04-02 20:51 执着追求的IT小小鸟 阅读(191) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1262从数的中间开始判断,如果都为素数,就可以输出View Code 1 #include<stdio.h> 2 int prime(int n)//判断素数 3 { 4 int i; 5 for(i=2;i<=n/2;i++) 6 if(n%i==0) 7 return 0; 8 return 1; 9 }10 int main()11 {12 int m,a;13 while(scanf("%d",&m)!=EOF)14 {15 for(a=m/2;a> 阅读全文
posted @ 2013-03-31 00:00 执着追求的IT小小鸟 阅读(138) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=564解法和杭电acm1042一样,输出格式不一样View Code 1 #include<stdio.h> 2 int main() 3 { 4 long n,m,i,j,b; 5 long a[100000]; 6 while(scanf("%ld",&n)!=EOF) 7 { 8 9 a[0]=1;10 m 阅读全文
posted @ 2013-03-30 19:20 执着追求的IT小小鸟 阅读(102) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1042这题很有难度,对现在的自己而言。。。。因为比较大的数的阶乘结果即使longlong也是存不下的,所以用数组来做,可以每个位上存1位或者多位,先总的每个位上的元素乘上要计算的那个数,然后依次取模和进位,存储及进位到下一位。。。得到结果View Code 1 #include<stdio.h> 2 int main() 3 { 4 int n,m,i,j,b; 5 long a[100000]; 6 while(scanf("%d",&n)!=EOF) 7 { 8 . 阅读全文
posted @ 2013-03-30 19:05 执着追求的IT小小鸟 阅读(257) 评论(0) 推荐(0) 编辑
摘要: qsort包含在<stdlib.h>头文件中,此函数根据你给的比较条件进行快速排序,通过指针移动实现排序。排序之后的结果仍然放在原数组中。使用qsort函数必须自己写一个比较函数。函数原型:void qsort ( void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) );用法以及参数说明:Sorts the num elements of the array pointed by base, each element size bytes long, us 阅读全文
posted @ 2013-03-30 00:27 执着追求的IT小小鸟 阅读(136) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2031典型的禁制转化,除k取余,然后颠倒输出View Code 1 #include<stdio.h> 2 char ans[100000]; 3 void zhuanhua(int n,int r) 4 { 5 int i,j; 6 char a[100000]; 7 i=j=0; 8 while(n) 9 {10 if(n%r>9)11 a[i]=n%r-10+'A';//大于10的用16进制的表示 12 else 13 a[i]=n%r+'0';1... 阅读全文
posted @ 2013-03-29 23:32 执着追求的IT小小鸟 阅读(184) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2039两边之和大于第三边View Code 1 #include<stdio.h> 2 int main() 3 { 4 double a,b,c; 5 int n; 6 while(scanf("%d",&n)!=EOF) 7 while(n--) 8 { 9 scanf("%lf%lf%lf",&a,&b,&c);10 if(a+b>c&&a+c>b&&c+b>a)11 p 阅读全文
posted @ 2013-03-29 22:44 执着追求的IT小小鸟 阅读(137) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1061看最后一位数字的次方1的所有次方都是10的所有次方都是05的所有次方都是56的所有次方都是62(四个一循环)3(四个一循环)7(四个一循环)8(四View Code 1 #include<stdio.h> 2 int print(int n) 3 { 4 int i,n0=n%10,j,ans; 5 if(n0==0||n0==1||n0==5||n0==6)//直接输出 6 return n0; 7 if(n0==2||n0==3||n0==7||n0==8) 8 { 9 ... 阅读全文
posted @ 2013-03-29 20:34 执着追求的IT小小鸟 阅读(270) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 27 下一页