
素数
gtuif
大多数人永远都不会了解真实的你,但是他们会看到你所做的一切。。。
展开
-
素数筛选(转载)
素数筛选: 所谓的素数筛选其实依据一个bool型数组来实现筛选。将数组下标为奇数的等于true,偶数为false. 然后: for( i=3; i {原创 2017-01-17 18:48:05 · 280 阅读 · 0 评论 -
素数打表(小模板)
#include #include const int N=1000; int pre[1000]; void prime() { memset(pre,0,sizeof(pre)); for(int i=2;i*i<N;i++) if(!pre[i]) for(int j=i*2;j<N;j+=i) pre[j]=1; } int main() { int n,i; p原创 2017-04-07 17:45:06 · 287 阅读 · 0 评论 -
素数打表的四种解法
题目:给出一个正整数n,打印出所有从1~n的素数(即质数); 1.傻瓜解法 复制代码 int i,n; while(scanf("%d",&n)!=EOF) { for(i=2;i<n;i++) if(n%i==0) break; if(i==n) printf("YES\n"); else printf("NO\n"); }转载 2017-06-26 08:34:32 · 4316 阅读 · 0 评论 -
B - Factors of Factorial AtCoder - 2286
You are given an integer N. Find the number of the positive divisors of N!, modulo 109+7. Constraints 1≤N≤103 Input The input is given from Standard Input in the fo...原创 2018-03-27 16:15:44 · 196 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第三场) Diff-prime Pairs
链接:https://www.nowcoder.com/acm/contest/141/H 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Eddy has solved lots of problem involving calculating the numbe...原创 2018-08-14 22:05:04 · 236 阅读 · 0 评论