2011年7月22日

摘要: #include <stdio.h>#include <math.h>#define MAX 1000000int s[MAX];void Prime(){int i, j;for( i = 4; i < MAX; i += 2)s[i] = 1;for( i = 3; i < sqrt(MAX); i += 2){if( s[i] == 0 ){for( j = i*i; j < MAX; j += i)s[j] = 1;}}}int main(){int i;Prime();for( i = 2 ; i < MAX ; i++){if( s[ 阅读全文

posted @ 2011-07-22 23:49 continue_n 阅读(470) 评论(0) 推荐(0)

摘要: 二分法求幂:比如2的9次方可以看成 ((2的4次方)的平方)*2 ;2的8次方可以看成((2的4次方)的平方);依此类推……#include <stdio.h>/*int fun(int a,int n){if( n == 1 ) return a;int temp = (a*a) % 10000;if( n&1 ) return (fun(temp,n/2)*a) % 10000;else return (fun(temp,n/2)) % 10000;}*//*int fun(int a,int n){int s;s = 1;while(n){if( n & 1 阅读全文

posted @ 2011-07-22 23:48 continue_n 阅读(217) 评论(0) 推荐(0)


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3