description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
def printDivisors(n,a) :
i=2
f=0
while(i*i<=n):
if n%i==0:
j=i+1
n=n//i
while(j*j<=n):
if n%j==0:
if j!=n//j:
print('YES')
print(i,j,n//j)
f=... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def main():
def divisors(n):
div = []
for i in range(2, int(n**0.5)): #n//2 + 1):#int(n ** 0.5)):
if n % i == 0:
div.append(i)
n //= i
if len(div) == 2:
if n not in div and n != 1:
div.append(n)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
public class Main{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-->0){
int n = in.nextInt();
int count=0;
int a=0,b=0;
for(int i=2;i<=Math.sqrt(n);i++){
if(n%i==0){
n=n/i;
if(a==0){
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
T = int(input())
def check(n,p):
ans = -1
for i in range(p+1, int(math.sqrt(n)) + 1):
if n % i == 0:
ans = i
break
return ans
for i in range(T):
l = []
n = int(input())
ans = 'YES'
hello = 1
for i in range(3):
hello = check(n,hello... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for i in range(t):
n=int(input())
a=0
b=0
c=0
for i in range(2,int(n**0.5)+2):
if n%i==0:
n//=i
a=i
break
if a==0:
print("NO")
continue
else:
for j in range(a+1,int(n**0.5)+2):
if n%j==0 and n//j!=... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t = int(input())
while t>0:
t-=1
n = int(input())
sn = n
l = []
for i in range(2,int(math.sqrt(n))+1):
if n%i == 0:
l.append(i)
n = n//i
c = i
break
else:
print("NO")
continue
for i in range(c+1,int(math.sq... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
def fastio():
from io import StringIO
from atexit import register
global input
sys.stdin = StringIO(sys.stdin.read())
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.stdout = StringIO()
register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
def debug(*va... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def fact(n):
ans = 1
for i in range(2, n+1):
ans*= i
return ans
def comb(n, c):
return fact(n)//(fact(n-c)*c)
for _ in range(int(input())):
n= int(input())
ans = []
for i in range(2, int(math.sqrt(n))+1):
if(n%i==0 and i not in ans):
n//=i
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class Solution{
public static void main(String[] args){
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.ArrayList;
import java.util.BitSet;
import java.util.Scanner;
public class CF1294C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
BitSet sieve = new BitSet();
for(int i=2; i<=1000000; i++) sieve.set(i);
for(int i=2; i<=1000000; i++)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def getprod(n):
res = []
i = 1
while(i*i <= n):
if(n%i == 0):
res.append(i)
if(n//i != i):
res.append(n//i)
i += 1
return res
for _ in range(int(input())):
num = int(input())
res = getprod(num)
if(len(res) <= 2):
print('NO')
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//package ieee;
import java.util.Scanner;
import java.util.ArrayList;
/**
*
* @author LAPTOP
*/
public class IEEE {
/**
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
import java.io.*;
public class Product_of_Three_Numbers {
static int mod = (int) (1e9 + 7);
public static void main(String[] args) throws java.lang.Exception {
/*
Let a be the minimum divisor of n greater than 1.
Then let b be the minimum divisor of na that isn't equal a and 1.
If n/ab ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
I=sys.stdin.readline
ans=""
for _ in range(int(I())):
n=int(input())
fac=[(i,n//i) for i in range(2,int(n**.5)+1) if n%i==0]
#print(fac)
if len(fac)!=0:
x=fac[0][1]
flag=1
for i in range(2,int(x**.5)+1):
if x%i==0 and i!=fac[0][0]:
if i!=x//i:
ans+="YES\n"
ans+="{} {} {}\n".format(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | """T=int(input())
for _ in range(0,T):
n=int(input())
a,b=map(int,input().split())
s=input()
s=[int(x) for x in input().split()]
for i in range(0,len(s)):
a,b=map(int,input().split())"""
import math
T=int(input())
for _ in range(0,T):
N=int(input())
n=N
L=[]
while (n % 2 == ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
for q in range(t):
n=int(input())
m=n
fact=[]
while m%2==0:
fact.append(2)
m = m / 2
for i in range(3,int(math.sqrt(m))+1,2):
while m % i== 0:
fact.append(i)
m = m / i
if m > 2:
fact.append(m)
dist = lis... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
public static void process()throws IOException
{
int n=ni();
if(n==2){
pn("NO");
return;
}
ArrayList<Pair> li = new ArrayList<>();
int t=n;
long po=0l;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
set<int> used;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0 && !used.count(i)) {
used.insert(i);
n /= i;
break;
}
}
for (int i = 2; i * ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
void gao(int n) {
for (int i = 2; i * i < n; i++) {
if (n % i == 0) {
for (int j = i + 1; j * j < n / i; j++) {
if (n / i % j == 0) {
cout << "YES" << endl;
cout << i << ' ' << j << ' ' << n / i / j << endl;
return;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
FastReader scan = new FastReader();
//PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("marathon.out")));
PrintWriter out = new PrintWriter(new BufferedWr... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
import math
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
t = ini()
ans = []
andsindex = [0] * t
for _ in range(t):
n = ini()
i = 2
tmp = []
while n >= i * i:... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n, i, cnt = 0, d, ar[3];
cin >> n;
for (i = 2; i * i <= n; i++)
if (n % i == 0) {
ar[cnt++] = i;
n /= i;
if (cnt == 2) break;
}
if (cnt == 2) {
ar[2] = n;
sort(ar, ar + 3);
if (ar[0] != ar[1] && ar[1] != ar[2]... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | I = input
pr = print
def main():
for _ in range(int(I())):
ar=[]
n,i=int(I()),2
while i*i<n and len(ar)<2:
if n%i==0:ar.append(i);n//=i
i+=1
if len(ar)==2:pr('YES');pr(*ar,n)
else:pr('NO')
main() |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from sys import stdin, stdout
from math import sqrt
def solve():
n = int(input())
st = set()
for i in range(2, int(sqrt(n)) + 1):
if n%i == 0 and i not in st:
st.add(i)
n /= i
break
for i in range(2, int(sqrt(n)) + 1):
if n%i == 0 and i not in st:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
import java.io.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
static Scanner scanner=new Scanner(System.in);
public static void main(String[] args) {
int q=scanner.nextInt();
while(q-->0) {
int n=scanner.nextInt();
Set<Integer>set=new HashSet<Integer>();
for(i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import sqrt
def fact(k):
for i in range(2,(int(sqrt(k)+1))):
if k%i == 0:
if k//i != i:
f = k//i
return f,i
return 0,0
def main():
t = int(input())
for __ in range(t):
n = int(input())
flag = False
for i in range(2,... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
long long int vist[200001], maxx;
void dfs(long long int node) {
vist[node] = 1;
maxx = max(maxx, node);
for (long long int child : adj[node])
if (!vist[child]) dfs(child);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL)... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void printDivisors(long long n, set<long long> &s, vector<long long> &v) {
for (long long i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i) {
s.insert(i);
v.push_back(i);
} else {
s.insert(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t = int(input())
for i in range(t):
a = 0
b = 0
n = int(input())
for j in range (int(math.sqrt(n))-1):
if n%(j+2) == 0:
n = n//(j+2)
a = j+2
break
if a == 0:
print("NO")
elif a != 0:
for j in range (int(math.sqrt(n))-2):
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t = int(input())
for xx in range(t):
n = int(input())
i = 2
fl = 0
divs = []
while(i*i <= n):
if n%i == 0:
divs.append(i)
n//=i
if len(divs) == 2:
break
i += 1
if len(divs) < 2: fl = 1
if fl == 1:
print("NO")
continue
kr = n
if kr == 1 or kr == divs[0] or kr == divs[1]:
print... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | a, i = int(input()), 0
def pro(a):
p, i = 0, 2
while i * i <= a:
if a % i == 0:
p = i
break
i = i + 1
return p
def f1(k, ak, a):
i, t = 2, 0
while i * i <= ak:
if a % i == 0:
if ak // i != i and i != k and (ak // i) * i * k == a:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for _ in range(int(input())):
x = int(input())
li = []
for i in range(2,int(x**0.5) +1):
if x%i==0:
li.append(i)
x = x//i
break
for i in range(2,int(x**0.5) +1):
if x%i==0 and i not in li:
li.append(i)
x = x//i
break
if len(li) <2 or x==1 or x in li:
print('NO')
else:
print('YES')
prin... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.*;
import java.util.*;
public class ProductofThreeNumbers {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0) {
int n = in.nextInt();
int a,b,c;
a=b=c=-1;
for(i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def factor(n):
dict1={}
for i in range(2,int(pow(n,0.5))+1):
if n%i==0:
if i not in dict1:
dict1[i]=1
if n//i not in dict1:
dict1[n//i]=1
return dict1
for t in range(int(input())):
n=int(input())
dict1=factor(n)
dic... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
int num[maxn], cnt;
int seq[maxn];
bool Find(int res, int now) {
for (int i = 1; i <= now; i++) {
if (seq[i] == res) return true;
}
return false;
}
void Init();
int main() {
int T;
scanf("%d", &T);
while (T--) Init();
return 0... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> v;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
v.push_back(i);
if (v.size() == 2) {
v.push_back(n / i);
break;
}
n /= i;
}
}
v.erase(unique(v.begin(), v.end()), ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for i in range(t):
n=int(input())
l=[0, 0, 0]
tmp=0
m=n
i=2
while i**2<=m and tmp<2:
if n%i==0:
n//=i
l[tmp]=i
tmp+=1
i+=1
if tmp==2 and n>l[1]:
print("YES")
l[2]=n
print(*l)
else:
print("N... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.Scanner;
public class Product_Of_Three_Numbers {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
//System.out.println("Enter the number of test cases :");
int t=sc.nextInt();
for(int i=0;i<t;i++) {
int n=sc.nextInt();
find(n);
}
}
public static vo... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for t in range(int(input())):
n=int(input())
flag=0
for i in range(2,10001):
if(n%i==0):
flag=1
break
if(flag==1):
a=i
n=n//i
for i in range(2,100001):
if(n%i==0 and i!=a):
flag=2
break
b=i
c=n//i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def printDivisors(n) :
i = 2
c = []
while i <= math.sqrt(n):
if (n % i == 0) :
if (n / i == i) :
c.append(n//i)
else :
c.extend([i,n//i])
i = i + 1
return c
def countTriplets(arr, n, m):
count = 0
arr.sort()
for end in range(n - 1, 1, -1):
start = 0
m... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.Map.*;
public class codeforces {
public static void main(String [] args) throws IOException, InterruptedException {
Scanner sc=new Scanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
int t=sc... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
import math
import heapq
import bisect
import re
from collections import deque
from decimal import *
from fractions import gcd
def main():
# [int(i) for i in sys.stdin.readline().split()]
n = int(sys.stdin.readline())
q = []
for i in range(int(n ** 0.5) + 1, 0, -1):
if n % i == 0:... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
from functools import reduce
t = int(input())
for cas in range(t):
n = int(input())
ans = []
m = n
for i in range(2, int(math.sqrt(m))):
cal = 0
if n == 1:
break
while n % i == 0 and n > 1:
n //= i
ans.append(i)
if n > 1:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def fun(s):
for i in range(2, int(math.sqrt(s)) + 1):
if s % i == 0:
w = s // i
for j in range(i + 1, int(math.sqrt(w) + 1)):
d = w // j
if w % j == 0 and d != j and d != i:
return i, j, d
return -1
for t in rang... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
for i in range(t):
n = int(input())
a, x, d = [], 0, 2
while d * d <= n and x < 2:
if n%d == 0:
a.append(d)
n = n // d
x += 1
d += 1
if n >= d and x == 2:
a.append(n)
print("YES")
res = " ".join(map(str, a))
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def fun(n):
for i in range(2,int(n**0.5)+1):
x=n//i
if n%i==0:
for j in range(2,int(x**0.5)+1):
if x%j==0 and x//j!=j and i!=j and x//j!=i:
return True,[i,j,x//j]
return False,[-1,-1,-1]
t=int(input())
for _ in range(t):
n=int(input())
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def primenum(x):
count=0
for i in range(2,int(math.floor(math.sqrt(x)))+1):
if(x%i==0):
count=count+1
if(count==0):
return True
else:
return False
t=int(input())
for i in range(t):
n=int(input())
m=n
if(primenum(n)==True):
print('NO')
else:
l=[]
for j in range(2,int(math.sqrt(m))+1):
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
class Read:
@staticmethod
def string():
return input()
@staticmethod
def int():
return int(input())
@staticmethod
def list(sep=' '):
return input().split(sep)
@staticmethod
def list_int(sep=' '):
return list(map(int, input().split(sep)))
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long i, j, k, n;
cin >> n;
map<long long, long long> mp;
long long x = n;
while (x % 2 == 0) {
mp[2]++;
x /= 2;
}
for (i = 3; i * i <= x; i += 2) {
while (x % i == 0) {
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for _ in range(t):
n=int(input())
a,b,c=0,0,0
flag=0
flg=0
cnt=0
mx=2
l=[]
if(n<24):
print("NO")
else:
for _ in range(3):
for i in range(mx, int(n**0.5) + 1):
if n % i == 0:
flg=1
bre... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import sqrt
N = int(input())
for i in range(N):
n = int(input())
res = []
is_good = False
for i in range(2, n//6 + 1):
if i > sqrt(n):
break
if n % i == 0:
res.append(i)
n /= i
if len(res) == 2:
if n > i:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
from math import *
import bisect
for i in range(t):
n = int(input())
x = set()
for j in range(2,int(sqrt(n))+1):
if(n%j==0):
x.add(j)
if(n%(n//j)==0):
x.add(n//j)
x = list(x)
x.sort()
flag = 0
for j in range(len(x)):
for k in range(j+1,len(x)):
y = n/(x[j]*x[k])
if(y in x and y... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
for _ in range(t):
n = int(input())
ans = []
i = 2
top = 10**6
while len(ans) < 2 and i <= n and i <= top:
if n%i == 0:
n //= i
ans.append(i)
i += 1
if len(ans) < 2 or n == 1 or n in ans:
print('NO')
else:
print('YES')
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> f, c;
int r = n;
int co{0};
while (r % 2 == 0) {
r = r / 2;
co++;
}
if (co > 0) {
f.push_back(2);
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for t in range (t):
n=int(input())
d=2
cate=0
vec=[0]*10
while d*d <= n:
if(n%d == 0 and cate<2):
vec[cate]=d
cate+=1
n/=d
if cate == 2:
break
d+=1
if n > 1 and cate == 2:
vec[cate]=n
cate+=1
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def primeFactors(n):
f = []
while n % 2 == 0:
f.append(2),
n = n / 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
f.append(i),
n = n / i
if n > 2:
f.append(n)
return f
t = int(input())
while t>0:
n = int(inp... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | # -*- encoding: utf-8 -*-
import sys
import math
r_input = sys.stdin.readline
def get_divisor(num):
divisors = []
length = int(math.sqrt(num)) + 1
for i in range(1, length):
if num % i == 0:
divisors.append(i)
divisors.append(num // i)
return divisors
if __name__ == ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int MAXN = (int)1e5 + 5;
const int MOD = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
bool mul(int n, int& a, int& b, int& c) {
a = INF, b = INF, c = INF;
for (int i = 2; i * i *... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from sys import stdin,stdout
t = 1
t=int(input())
def factorgreaterthan(n,x):
i=x+1
while (i*i)<=n:
if n%i==0:
return i
i+=1
return n
for i in range(t):
n=int(input())
N=n
l=[]
d1=factorgreaterthan(n,1)
n//=d1
l.append(d1)
d2=factorgreaterthan(n,d1)
n//=d2
l.append(d2)
l.append(n)
l.sort()
m=1
fl... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def Divisors(number):
Div=set()
sqr=int(number**0.5)
for i in range(2,sqr+1):
if number%i==0:
Div=Div|{i}
Div=Div|{(number//i)}
return list(Div)
def getDiv(Number):
D=list(Divisors(Number))
D.sort()
for i in range(len(D)):
for j in range(i+... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
void err() { cout << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) {
cout << arg << ' ';
err(args...);
}
using ll = long long;
using db = double;
using pII = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
public class Unusual_Competitions {
public static void main(String[] args) throws N... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | t = int(input())
from collections import defaultdict
for _ in range(t):
dic = defaultdict(int)
dic2 = defaultdict(int)
n = int(input())
bl = list(map(int,input().split()))
for idx, b in enumerate(bl):
dic[b] = idx + 1
bl_sort = sorted(bl)
s = 0
kouho = []
for b in range(1, ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
long long int modPow(long long int x, long long int n, long long int mod) {
long long int r = 1;
x = x % mod;
while (n) {
if (n & 1) r = (r * x) % mod;
n = n >> 1;
x = (x * x) % mod;
}
return r;
}
int main() {
long long int t, i, j, k, l, n, m, a, b,... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | t=int(input())
for q in range(t):
n=int(input())
arr=list(map(int,input().split()))
marked=[0]*(2*n+1)
for i in range(len(arr)):
marked[arr[i]]=1
#print(marked)
ans=[]
for i in range(n):
ans.append(arr[i])
for j in range(arr[i]+1,len(marked)):
if marked[j]... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
const int N = 105;
int T, n, tot;
int a[N], b[N << 1];
bool vis[N << 1];
int main() {
scanf("%d", &T);
while (T--) {
memset(vis, false, sizeof(vis));
scanf("%d", &n);
for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]), vis[a[i]] = true;
bool jay = ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")
using namespace std;
const double... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | t=int(input())
for i in range(t):
n=int(input())
arr=list(map(int,input().split()))
ans=[]
for i in range(1,len(arr)*2+1):
if i not in arr:
ans.append(i)
fina=[]
for i in range(len(arr)):
fina.append(arr[i])
for j in range(len(ans)):
if ans[j]>arr... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import java.util.*;
public class Solutions {
static Scanner scr=new Scanner(System.in);
public static void main(String[] args) {
int t=read();
while(t-->0) {
solve();
}
}
static void solve() {
int n=read();
int []a=new int[n];
int []count=new int[2*n+1];
for(int i=0;i<n;i++) {
a[i]=read();
co... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | # import sys
# input = sys.stdin.readline
# from bisect import bisect_left, bisect_right
# INF = 1 << 60
t = int(input())
for i in range(t):
n = int(input())
b = list(map(int, input().split()))
c = [0 for i in range(2 * n)]
ans = []
possible = True
for j in b:
c[j - 1] = 1
for j in ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | t=int(input())
for _ in range(t):
n=int(input())
b=[int(s) for s in input().split()]
vmax=max(b)
vmin=min(b)
a=[]
for i in range(0,n):
a.append(b[i])
k=b[i]
while k in b or k in a:
k+=1
if k>2*n:
print(-1)
break
a.append... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... |
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while (T-->0)
{
int N = sc.nextInt();
int[] list = new int[N+1]... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import java.util.*;
import java.io.*;
public class Main {
static StringBuilder sb = new StringBuilder();
static BufferedReader br = null;
static StringTokenizer st = null;
static int n;
static int[] ba;
static boolean[] ck;
public static void main(String[] args) throws Exception {
br = ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | def solve(n,b):
if 1 not in b or 2*n in b:
return ([-1])
else:
s=set(b)
arr=[]
for i in range(n):
j=b[i]+1
while True:
if j not in s and j<=2*n:
arr.append(j)
s.add(j)
break
... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | from bisect import bisect
for _ in range(input()):
n = input()
a = map(int,raw_input().split())
if 1 not in a or 2*n in a:
print -1
continue
l = []
for i in range(1,2*n+1):
if i not in a:
l.append(i)
d = {}
f = 0
for i in range(n):
p = bisect(l... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import bisect
t=int(input())
def find_gt(a, x):
'Find leftmost value greater than x'
i = bisect.bisect_right(a, x)
if i != len(a):
return a[i]
raise ValueError
for _ in range(t):
b=int(input())
B=list(map(int,input().split()))
d={}
v=[0]
x=[]
y=[]
for i in range(1,2*... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class C implements Runnable {
private void solve() throws IOException {
int t = nextInt();
outer2: while(t-- > 0) {
int n = nextI... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(2 * n + 1), b(n + 1), c(2 * n + 1, 0);
set<int> d;
for (int i = 1; i <= n; i++) {
cin >> b[i];
c[b[i]] = 1;
}
... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import sys,os,io
# input = sys.stdin.readline # for strings
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # for non-strings
PI = 3.141592653589793238460
INF = float('inf')
MOD = 1000000007
# MOD = 998244353
def bin32(num):
return '{0:032b}'.format(num)
def add(x,y):
return (x+y)%MOD
def ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
int arr[1005];
int counter[1005];
int main() {
int tc;
cin >> tc;
while (tc--) {
memset(arr, 0, 1005);
memset(counter, 0, 1005);
int flag = 0;
vector<int> v;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
counter[... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
n=int(input())
B=list(map(int,input().split()))
USE=[0]*(2*n+1)
A=[-1]*(2*n)
for i in range(n):
A[2*i]=B[i]
USE[B[i]]=1
for i in range(2*n):
if A[i]!=-1:
continue
for j in ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | for _ in range(int(input())):
n=int(input())
b=[int(i) for i in input().strip().split()]
taken=set(b)
lim=2*n
a=[]
for x in b:
done=False
pairx=None
for y in range(x+1,lim+1):
if y not in taken:
done=True
pairx=y
... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
int vis[205], p = 0;
memset(vis, 0, sizeof(vis));
while (t--) {
++p;
int n, b[205];
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> b[i]... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | t=int(input())
while(t):
t-=1
n=int(input())
li=list(map(int,input().split()))
b_li=[0]*(2*n)
for i in range(0,n):
b_li[i*2]=li[i]
have=[]
for i in range(1,2*n+1):
if i not in li:
have.append(i)
for i in range(1,2*n+1,2):
pre=b_li[i-1]
flag=0
... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... |
import java.util.*;
import java.lang.*;
import java.io.*;
public class cf {
static PrintWriter out;
static int MOD = 1000000007;
static FastReader scan;
/*-------- I/O using short named function ---------*/
public static String ns() {
return scan.next();
}
public static int ni()... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
b = [i for i in range(1,2*n+1) if i not in a]
sol = [0]*(2*n)
for i in range(len(a)):
tmp=[j for j in b if j>a[i]]
if len(tmp)==0:
sol=-1
break
else:
sol[2*i]=a[i... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
int t, n;
int main() {
cin >> t;
while (t--) {
int f = 0;
cin >> n;
vector<int> a;
a.push_back(0);
map<int, int> m;
int b[2 * n + 5];
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
if (x >= 2 * n) f = 1;
a.push_back(x... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5 + 1;
void setIO(string name) {
ios_base::sync_with_stdio(0);
cin.tie(0);
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
int main() {
in... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const long long mod = 1e9 + 7;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const long long MX = LLONG_MAX;
const long long... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #import sys
#import math
#sys.stdout=open("C:/Users/pipal/OneDrive/Desktop/VS code/python/output.txt","w")
#sys.stdin=open("C:/Users/pipal/OneDrive/Desktop/VS code/python/input.txt","r")
t=int(input())
for i in range(t):
n=int(input())
l=list(map(int,input().split()))
if 1 not in l:
print("-1")
... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | I=input
for _ in[0]*int(I()):
n=2*int(I());a=[0]*n;b=a[::2]=*map(int,I().split()),;c={*range(1,n+1)}-{*b};i=1
try:
for x in b:y=a[i]=min(c&{*range(x,n+1)});c-={y};i+=2
except:a=-1,
print(*a) |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | def solve(N, B):
A = [0] * (2 * N)
check = [False] * (2 * N)
flag = True
for i in range(N):
A[i*2] = B[i]
check[B[i]-1] = True
for i in range(N):
tmp = A[i*2]
for j in range(tmp, 2*N):
if not check[j]:
A[i*2+1] = j+1
check[j... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | import math
import heapq
import sys
num = int(raw_input())
for i in range(num):
n = int(raw_input())
nums = [int(x) for x in raw_input().split(" ")]
if 1 not in nums:
print("-1")
continue
cur_set = set()
for nn in nums:
cur_set.add(nn)
ans = []
flag = 0
for nn in ... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epo... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | t=int(input())
for i in range(0,t):
o=[]
n=int(input())
l=list(map(int,input().split()))
e=0
for j in range(0,len(l)):
o.append(l[j])
c=l[j]+1
if c>2*n:
e=1
break
else:
while c in l or c in o:
c+=1
if... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | for T in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
Ans = []
Exist = [False] * (2 * n + 100)
Bad = False
for i in b : Exist[i] = True
for i in range(n):
Ans.append(b[i])
Number = b[i] + 1
while Exist[Number] == True and Number < 2 * n: N... |
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | #include <bits/stdc++.h>
using namespace std;
set<int> prime;
void SieveOfEratosthenes(int n) {
bool prme[n + 1];
memset(prme, true, sizeof(prme));
for (int p = 2; p * p <= n; p++) {
if (prme[p] == true) {
for (int i = p * p; i <= n; i += p) prme[i] = false;
}
}
for (int p = 2; p <= n; p++)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.