敲错了,是VS2010
直接在打开方式里选就行
直接在打开方式里选就行
[fly]存在即是合理[/fly]
#include<stdio.h> #include<stdlib.h> #include<time.h> int isprime(int n) { int ps[32], a, p, x, r, t, i, j; for(t = -1, p = n - 1; p; p >>= 1) ps[++t] = p & 1; for(i = 0; i < 16; i++) { a = (rand() % (n - 2)) + 2; for(r = 1, j = t; j >= 0; j--) { x = r; r = ((long long)x * x) % n; if(r == 1 && x != 1 && x != n - 1) return 0; if(ps[j]) r = (long long)r * a % n; } if(r != 1) return 0; } return 1; } int main() { int i, c, t0; srand(time(NULL)); t0 = clock(); for(c = 2, i = 5; i <= 10000000; i += 2) c += isprime(i); printf("count = %d\nuse time %.3f s\n", c, (double)(clock() - t0) / 1000); return 0; }