From a5b097f9136cf458d8b95350a05ac19a99f3cbf3 Mon Sep 17 00:00:00 2001 From: Priyanshu Sinha Date: Tue, 30 Oct 2018 23:38:52 +0530 Subject: [PATCH] implementation of sieve's algorithm --- C-C++/implementation of sieve_algorithm.cpp | 85 +++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 C-C++/implementation of sieve_algorithm.cpp diff --git a/C-C++/implementation of sieve_algorithm.cpp b/C-C++/implementation of sieve_algorithm.cpp new file mode 100644 index 0000000..dbc212d --- /dev/null +++ b/C-C++/implementation of sieve_algorithm.cpp @@ -0,0 +1,85 @@ +/* +All submissions for this problem are available.Prime numbers are arranged in a ordered list U, in increasing order. Let S be a sublist of U with a unique property that for every element A belonging to list S, if i denotes the index of A in list U, than i also belongs to list U. + +Given N, find sum of first N elements of list S, assuming 1-based indexing. + +As the sum can be very large, print the sum modulo 109+7. + +Input: +-The first line of the input contains a single integer T denoting the number of test cases. + +-Only line of each test case has an integer N . + +Output: +For each test case, print a single integer denoting the sum of first N elements of set S modulo 109+7. + +Constraints +1=T=10000 +1=N=1000*/ +#include +#include +#include +using namespace std; +int v[100000]={0}; +int su[100000]={0}; +int prime[100000]; +void calculate() +{ + int i,j; + int sum; + v[0]=1; + v[1]=1; + su[0]=0; + for(i=2;i>t; + + // vector v; + + while(t--) + { + cin>>n; + // cout<