Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ll> vll;
#define all(v) v.begin(),v.end()
#define sz(x) (int)(x).size()
#define alr(v) v.rbegin(),v.rend()
#define pb push_back
#define S second
#define F first
#define pow2(x) (1<<(x))
#define sp(x) cout<<fixed<<setprecision(6)<<x
#define output(x) cout<<(x?"YES\n":"NO\n")
#define bp(x) __builtin_popcount(x)
//#define int long long
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int inf=2e9;
const int N=1e6+1;
const char nl='\n';
const ll mod=1e9+7;
const ll Binf=1e18;
const ll mod1=998244353;
vector<int> lp(N+1);
vector<int> pr;
void liner_sieve(){
for (int i=2; i <N; ++i) {
if (lp[i] == 0) {
lp[i] = i;
pr.push_back(i);
}
for (int j=0; j < (int)pr.size() && pr[j] <= lp[i] && i*pr[j] <= N; ++j) {
lp[i * pr[j]] = pr[j];
}
}
}
void solve101(){
// debug(sz(pr));
int n;
cin>>n;
int rem=n%3;
if(rem==0)
cout << "6 10 15 " ;
else if(rem==1)
cout << "21 14 10 15 ";
else
cout << "33 77 14 10 15 ";
n-=n%3+3;
vector<int>temp={6,10,15};
int j=0;
for(int i=0;i<n;i++){
cout<<pr[i+5]*temp[j]<<" ";
j=(j+1)%3;
}
cout<<nl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
liner_sieve();
// debug(pr);
cin>>t;
for(int i=1;i<=t;i++){
// cout<<"Case #"<<i<<": ";
solve101();
}
cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
return 0;
}
// always check for binary search >.<
// #ifndef ONLINE_JUDGE
// if (fopen("input.txt", "r"))
// {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// }
// #endif
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main()
{
FIO;
int t,n,i,j,arr[]={6,10,15};
bool a[1000001]={0};
vector<int> v;
for(i=2;i<1000001;i++)
if(!a[i]){
v.push_back(i);
for(j=i;j<1000001;j+=i)
a[j]=true;
}
cin >> t;
while(t--)
{
cin >> n ;
i=n%3;
if(i==0)
cout << "6 10 15 " ;
else if(i==1)
cout << "21 14 10 15 ";
else
cout << "33 77 14 10 15 ";
n-=n%3+3;
for(i=0;i<n;i++)
cout << v[i+5]*arr[i%3] << ' ';
cout << '\n';
}
return 0;
}
//output
# cook your dish here
from sys import stdin,stdout
a=[0 for i in range(50005)]
pri=[0 for i in range(1000005)]
p=[0 for i in range(1000005)]
def prime(n):
ps=0
for i in range(2,n+1):
if p[i]==0:
pri[ps+1]=i
ps+=1
j=1
while j<=ps and i*pri[j]<=n:
p[i*pri[j]]=1
if i%pri[j]==0:
break
j+=1
def main():
t=stdin.readline()
t=int(t)
prime(1000000)
#print(pri[0:100])
for _ in range(t):
n=stdin.readline()
n=int(n)
if n==3:
stdout.write("6 10 15\n")
elif n==4:
stdout.write("10 15 21 14\n")
elif n==5:
stdout.write("78 10 105 77 143\n")
else:
cnt=(3-(n-1)%4)*4
j=3
for i in range(1,n+1,4):
if i<=cnt:
stdout.write(str(2*pri[j])+" "+str(pri[j]*pri[j+1])+" "+str(2*pri[j+1])+" ")
else:
stdout.write(str(2*pri[j])+" "+str(3*pri[j])+" "+str(3*pri[j+1])+" "+str(2*pri[j+1])+" ")
j+=2
stdout.write("\n")
main()
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#define mod 1000000007
long long int max=612000;
int primes[612000];
void sieve(int n)
{
//if 0 then prime else if 1 not prime
// int primes[max];
if(n<=3333)
{
max=200000;
}
else
{
max=612000;
}
long long int i,j;
memset(primes,0,max*(sizeof(primes[0])));
for(i=2;i<max;i++)
{
if(primes[i]==0)
{
for(j=2*i;j<max;j=j+i)
{
primes[j]=1;
}
}
}
}
void printsequence(int n)
{
sieve(n);
long long int b[n],k=0,i;
for(i=13;i<max;i++)
{
if(k<n)
{
if(primes[i]==0)
{
b[k]=i;
k++;
}
}
else
{
break;
}
}
//printf("k last=%lld\n",b[k-1]);
if(n==3)
{
printf("6 15 10\n");
}
else
{
long long int ans[n];
k=0;
for(i=0;i<(n-2);i++)
{
if(i%3==0)
{
ans[i]=b[k]*6;
}
else if(i%3==1)
{
ans[i]=b[k]*15;
}
else
{
ans[i]=b[k]*10;
}
k++;
}
k--;
//i--;
ans[i]=b[k]*7;
//printf("i==%lld\n",b[k]);
i++;
ans[i]=7*11;
ans[0]=ans[0]*11;
for(i=0;i<n;i++)
{
printf("%lld ",ans[i]);
}
printf("\n");
}
}
int main()
{
int m,t;
scanf("%d",&t);
for(m=0;m<t;m++)
{
int n;
scanf("%d",&n);
printsequence(n);
}
return 0;
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.io.*;
class Sequences {
static FastReader in;
static PrintWriter out;
static final int MAXN = (int) 1e6;
static int spf[] = new int[MAXN];
static ArrayList<Integer> primes = new ArrayList<>();
public static void main(String[] args) throws Exception {
in = new FastReader();
out = new PrintWriter(System.out);
sieveOfEratosthenes(MAXN);
int tc = in.nextInt();
for(int t = 0; t < tc; t++) {
solve();
}
out.flush();
out.close();
}
static void solve() throws Exception {
int n, seq[];
n = in.nextInt();
seq = new int[n];
Arrays.fill(seq, 1);
int resp[] = new int[]{2, 3, 5};
int np = 4, respi = 0;
for(int i = 0; i < n; i++) {
int mul;
if(i % 2 == 0) {
mul = primes.get(np++);
}
else {
mul = resp[respi];
respi = (i+1)%3;
}
if(i == n-1) mul = 7;
seq[i] *= mul;
seq[(i+1)%n] *= mul;
}
// pn(isValid(seq, n));
for(int i = 0; i < n; i++) {
p(seq[i] + " ");
}
pn("");
}
static boolean isValid(int[] seq, int n) {
int pg;
for(int i = 0; i < n; i++) {
if((pg = gcd(seq[i], seq[(i+1)%n])) == 1 || gcd(pg, seq[(i+2)%n]) != 1) {
pn(seq[i] + " " + seq[(i+1)%n] + " " + seq[(i+2)%n]);
return false;
}
}
return true;
}
static void sieveOfEratosthenes(int n) {
boolean prime[] = new boolean[n+1];
for(int i=0;i<n;i++)
prime[i] = true;
for(int p = 2; p*p <= n; p++) {
if(prime[p]) {
for(int i = p*p; i <= n; i += p)
prime[i] = false;
}
}
for(int i = 2; i <= n; i++) {
if(prime[i])
primes.add(i);
}
}
static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
static void p(Object o) {out.print(o);}
static void pn(Object o) {out.println(o);}
static void pnf(Object o) {out.println(o);out.flush();}
static class FastReader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public FastReader()
{
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public FastReader(String file_name) throws IOException
{
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException
{
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1)
{
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException
{
int ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do
{
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException
{
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException
{
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.')
{
while ((c = read()) >= '0' && c <= '9')
{
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException
{
if (din == null)
return;
din.close();
}
}
}
def sieve():
n = 1000000
lp = [0]*(n+1)
pr = []
for i in range(2,n+1):
if lp[i] == 0:
lp[i] = i
pr.append(i)
j = 0
while(j < len(pr) and pr[j] <= lp[i] and (i * pr[j]) <= n):
lp[i*pr[j]] = pr[j]
j = j+1
return pr
o = sieve()
o.pop(0)
o.pop(0)
o.pop(0)
o.pop(0)
o.pop(0)
for _ in range(int(input())):
n = int(input())
if n == 3:
l = [6,10,15]
print(*l)
continue
if n == 4:
l = [21, 14, 10, 15]
print(*l)
continue
if n == 5:
l = [33, 77, 14, 10, 15]
print(*l)
continue
if n%3 == 0:
l = [6,10,15]
n = n-3
cnt = 0
while(cnt < n):
if cnt%3 == 0:
l.append(6*o[cnt])
#print(o[cnt])
if cnt%3 == 1:
l.append(10*o[cnt])
#print(o[cnt])
if cnt%3 == 2:
l.append(15*o[cnt])
#print(o[cnt])
cnt = cnt+1
print(*l)
continue
if n%3 == 1:
l = [21,14,10,15]
n = n-4
cnt = 0
while(cnt < n):
if cnt%3 == 0:
l.append(6*o[cnt])
#print(o[cnt])
if cnt%3 == 1:
l.append(10*o[cnt])
#print(o[cnt])
if cnt%3 == 2:
l.append(15*o[cnt])
#print(o[cnt])
cnt = cnt+1
print(*l)
continue
if n%3 == 2:
l = [33, 77, 14, 10, 15]
n = n-5
cnt = 0
while(cnt < n):
if cnt%3 == 0:
l.append(6*o[cnt])
#print(o[cnt])
if cnt%3 == 1:
l.append(10*o[cnt])
#print(o[cnt])
if cnt%3 == 2:
l.append(15*o[cnt])
#print(o[cnt])
cnt = cnt+1
print(*l)
continue
# cook your code here
from fractions import gcd
arr = []
def func(arr,n):
p=2
prime = [True for i in range(n+1)]
while(p*p<=n):
if prime[p]==True:
for i in range(p*p,n+1,p):
prime[i]=False
p+=1
for p in range(2,n):
if prime[p]:
arr.append(p)
return arr
arr = func(arr,7*(10**5))
for _ in range(input()):
n = input()
ans = []
if n==3:
print 6,15,10
elif n==4:
print 374,595,1365,858
elif n==5:
print 6,15,35,77,286
elif n==7:
print 6,15,10,42,165,65,26
elif n==8:
print 6,15,10,42,165,130,13*19,19*2
elif n%3==0:
ans=[6,15,10]
for i in range(0,(n/3)-1):
ans.append(arr[(i+1)*3]*6)
ans.append(arr[(i+1)*3+1]*15)
ans.append(arr[(i+1)*3+2]*10)
print ' '.join(str(x) for x in ans)
elif n%3==1:
ans=[6,15,10]
for i in range(0,(n/3)-2):
ans.append(arr[(i+1)*3]*6)
ans.append(arr[(i+1)*3+1]*15)
ans.append(arr[(i+1)*3+2]*10)
ans.append(arr[(i+2)*3]*6)
ans.append(arr[(i+2)*3+1]*15)
ans.append(arr[(i+2)*3+2]*5)
ans.append(arr[(i+2)*3+2]*2)
print ' '.join(str(x) for x in ans)
elif n%3==2:
ans=[6,15,10]
for i in range(0,(n/3)-2):
ans.append(arr[(i+1)*3]*6)
ans.append(arr[(i+1)*3+1]*15)
ans.append(arr[(i+1)*3+2]*10)
ans.append(arr[(i+2)*3]*6)
ans.append(arr[(i+2)*3+1]*15)
ans.append(arr[(i+2)*3+2]*5)
ans.append(arr[(i+2)*3+2]*7)
ans.append(14)
print ' '.join(str(x) for x in ans)
using System;
using System.Collections.Generic;
using System.Text;
namespace CodechefLongJan2019
{
class EARTSEQ
{
public static void Main()
{
// your code goes here
Solve();
}
public static void Solve()
{
int t = int.Parse(Console.ReadLine());
List<int> primes = seive(650000);
//Console.WriteLine(primes.Count);
int[] arr = new int[] {6, 10, 15};
while(t--> 0)
{
int n = int.Parse(Console.ReadLine());
int remain = n % 3;
StringBuilder sb = new StringBuilder();
switch (remain)
{
case 0:
sb.Append("6 10 15");
break;
case 1:
sb.Append("21 14 10 15");
break;
case 2:
sb.Append("33 77 14 10 15");
break;
}
n = n - remain - 3;
for(int i = 0; i < n; i++)
{
sb.Append(" ");
sb.Append(arr[i % 3] * primes[i + 3]);
}
Console.WriteLine(sb.ToString());
}
}
/// <summary>
/// Calulate primes from 0 to n inclusive
/// </summary>
/// <param name="n"></param>
/// <returns>List of primes.</returns>
private static List<int> seive(int n)
{
List<int> prime = new List<int>();
bool[] nums = new bool[n + 1]; // marked if visited.
nums[0] = nums[1] = true;
for(int i = 2; i * i <= n; i++)
{
if(!nums[i])
{
for(int j = i * i; j <= n; j += i)
{
nums[j] = true;
}
}
}
for(int i = 2; i <= n; i++)
{
if(!nums[i])
{
prime.Add(i);
}
}
return prime;
}
}
}
package main
import (
"bufio"
"fmt"
"os"
)
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
func scan(a ...interface{}) { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func print(a ...interface{}) { fmt.Fprint(writer, a...) }
// MAX var
var MAX = 700000
func main() {
defer writer.Flush()
primes := Sieve(MAX)
var n, t int
var r []int
scanf("%d\n", &t)
for ; t > 0; t-- {
scanf("%d\n", &n)
r = Solve(n, primes)
for i := 0; i < len(r); i++ {
printf("%d ", r[i])
}
printf("\n")
}
}
// Sieve func
func Sieve(n int) []int {
isprime := make([]bool, n)
prime := make([]int, 0)
SPF := make([]int, n)
for i := 2; i < n; i++ {
isprime[i] = true
}
for i := 2; i < n; i++ {
if isprime[i] {
prime = append(prime, i)
SPF[i] = i
}
for j := 0; j < len(prime) &&
i*prime[j] < n && prime[j] <= SPF[i]; j++ {
isprime[i*prime[j]] = false
SPF[i*prime[j]] = prime[j]
}
}
return prime
}
// Solve func
func Solve(n int, primes []int) []int {
r := make([]int, n)
r[0] = 2
r[1] = 2
for i := 1; i < n-1; i++ {
if i%3 == 0 {
r[i] *= 7
r[i+1] = 7
} else if i%3 == 1 {
r[i] *= 3
r[i+1] = 3
} else {
r[i] *= 5
r[i+1] = 5
}
}
r[n-1] *= 11
r[0] *= 11
for i := 0; i < n; i++ {
r[i] *= primes[i+5]
}
return r
}
In our experience, we suggest you solve this Yet Another Problem About Sequences CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Yet Another Problem About Sequences CodeChef Solution.
“I hope this Yet Another Problem About Sequences CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.
Keep Learning!