上一页 1 ··· 52 53 54 55 56 57 58 59 60 ··· 99 下一页

2011年7月21日

素数筛选高效算法

摘要: 用普通的筛法,1000 0000 的数,需要用时1600ms左右。#include <stdio.h>#include <string.h>#include <math.h> char dp[10000010]; const int inf = 10000001;int t = sqrt(inf); inline void prime ( ){ int i, j, k = 0,p; dp[1] = -1; for (i = 2; i <= t; i++) if( dp[i] != -1) { //p = inf / i; for (j = 2; j & 阅读全文

posted @ 2011-07-21 22:11 more think, more gains 阅读(261) 评论(0) 推荐(0)

数论学习之扩展欧几里德

摘要: 扩展欧几里德1.定义:扩展欧几里德定理 对于不完全为 0 的非负整数 a,b,gcd(a,b)表示 a,b 的最大公约数,必然存在整数对 x,y ,使得 gcd(a,b)=ax+by。2.c语言实现#include <stdio.h>int q,x, y;void swap ( int *x1, int *y1){ int temp; temp = *x1; *x1 = *y1; *y1 = temp;} void fun( int a, int b){ if (b == 0 ) { x = 1; y = 0; q = a; } else { fun ( b, a % b); in 阅读全文

posted @ 2011-07-21 17:16 more think, more gains 阅读(144) 评论(0) 推荐(0)

数论学习之同余 中国剩余定理

摘要: 1.同余定义:设两个整数a, b,正整数m, m | a - b, 即 m * c = k ( a - b),则称a 模m同余于b, 或a 与b 模m 同余,记做 a = b (mod m).2.同余性质:1) 自反性2) 传递性3) 对称性4) 若 a = b (mod m), c = d (mod m)则 a+b = b+ d(mod m) a - b= b - d(mod m) ac = bd (mod m);3.中国剩余定理CRT (中国剩余定理CRT)设m1,m2,...,mk是两两互素的正整数,即gcd(mi, mj) =1, i≠j, i,j = 1,2,...,k 则同余方程组 阅读全文

posted @ 2011-07-21 11:07 more think, more gains 阅读(1054) 评论(0) 推荐(1)

2011年7月20日

gdb 调试程序

摘要: gdb是个强大的调试 器,功能 非常 强大。在linux下,先用vim 写一个c语言文件。。 1 #include <stdio.h> 2 3 int fun( int x , int i) 4 { 5 if ( i == 0 ) 6 return 1; 7 else if (i == 1) 8 return x; 9 else 10 return x * fun ( x , i -1 );11 12 }13 14 int main( )15 {16 int N, t;17 scanf("%d", &N);18 t = fun ( N, 5);19 pr 阅读全文

posted @ 2011-07-20 12:28 more think, more gains 阅读(279) 评论(0) 推荐(1)

phone list

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <cstdlib>#include <istream>#define MAX 10struct Trie { Trie *next[MAX]; int v;};Trie *root;void creattrie(char *str){ int i, j, len, t; Trie *p, *q; p = root; len = strlen(str); for (i = 0; i < len; i++ 阅读全文

posted @ 2011-07-20 11:34 more think, more gains 阅读(127) 评论(0) 推荐(0)

上一页 1 ··· 52 53 54 55 56 57 58 59 60 ··· 99 下一页

导航