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)... | import java.util.ArrayList;
import java.util.Scanner;
public class C615
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner obj=new Scanner(System.in);
int t=obj.nextInt();
while (t-->0)
{
int n=obj.nextInt();
int k=n;
int c=0;
ArrayList<Integer> arr=new Array... |
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
# sys.stdin=open("input1.in","r")
# sys.stdout=open("outpul.out","w")
for _ in range(int(input())):
N=int(input())
Factors=[]
FLAG=0
for i in range(2,int(pow(N,0.5))+1):
if N%i==0:
X=i
Z=N//i
for j in range(2,int(pow(Z,0.5))+1):
if... |
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 prime(n):
if n<3:
return not n&1
res=True
i=2
while i*i<=n:
if n%i==0:
res=False
break
i+=1
return res
def sieve(n):
num=[ True ]*(n+1)
i=2
primes=[]
while i*i<n+1:
if num[i]:
j=i*i
while j<=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)... | from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value(): return tuple(map(int, input().split()))
def arr(): return [int(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 solve(unique,arr):
if len(unique) >= 3 and len(arr) >= 3:
a,b = unique[0],unique[1]
c = n//(a*b)
return [a,b,c]
elif len(unique) == 1 and len(arr) >= 6:
a,b = unique[0],pow(unique[0], 2)
c = n // pow(a, 3)
return [a,b,c]
elif len(unique) == 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 test in range(t):
n=int(input())
i=2
prev=n
fac=[]
while i*i <=n :
if n%i == 0:
n=n//i
fac.append(i)
prev=i
i+=1
if n > 1 :
fac.append(n)
while len(fac) > 3:
fac[2] = fac[2] * fac[3]
fac.pop(3)
... |
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 ProgEc {
public static void main(String[] args) throws Exception {
//FileInputStream inputStream = new FileInputStream("input.txt");
//FileOutputStream outputStream = new FileOutputStream("output.txt");
InputStream inputStream = System.in;
OutputStream o... |
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):
a,b,c,j=1,1,1,0
flag=1
num = int(input())
for j in range(2,int((num)**0.5)):
if num%j==0:
a=j
#print(a)
break
num=num//a
for k in range(j+1,num+1):
if k >(num**0.5):
break
if num%k==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)... | from math import sqrt
def calcul(x,message):
for j in range (2,int(sqrt(x))):
if x%j==0:
m=x/j
s=int(sqrt(m))
if j+1>s:
s=int(m/2)
for k in range (j+1,s+1):
if (m%k==0) and (int(m/k)!=k) and (int(m/k)!=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)... | #include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 29;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b... |
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 floor, sqrt
try:
long
except NameError:
long = int
def fac(n):
step = lambda x: 1 + (x<<2) - ((x>>1)<<1)
maxq = long(floor(sqrt(n)))
d = 1
q = 2 if n % 2 == 0 else 3
while q <= maxq and n % q != 0:
q = step(d)
d += 1
return [q] + fac(n // q) if q <= ... |
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())):
n=int(input())
l=[]
if(n%2==0):
l.append(2)
for i in range(3,int(pow(n,0.5))+1):
if(n%i==0):
if(n//i==i):
l.append(i)
else:
l.append(i)
l.append(n//i)
flag=0
for i 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)... | """
Author : Aman Thakur
mantra: chor kya hi kar sakte hai!!
"""
import math
class Solution:
def __init__(self):
self.c = 0
self.arr = []
# def solution(self):
# n = int(input())
#
# for i in range(2, int(math.sqrt(n)) + 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)... | from math import sqrt, ceil
for _ in range(int(input())):
n = int(input())
ans = "YES"
out = [0, 0, 0]
for i in range(2, int(ceil(sqrt(n)))):
if n % i == 0:
n //= i
out[0] = i
break
else:
ans = "NO"
if ans == "YES":
for j 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)... | import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class JavaApplication1 {
public static void main(String args[]) throws IOException {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int x = sc.nextInt();
List<Inte... |
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
tests = int(input())
prime = [1 for i in range(10**6)]
prime[0] = 0
prime[1] = 0
for i in range(2,10**6):
if(prime[i] == 1):
for j in range(i*i,10**6,i):
prime[j] = 0
#prime_list = []
for te in range(tests):
n = int(input())
count = 0
prime_list = []
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)... | #include <bits/stdc++.h>
using namespace std;
map<string, long long int> m;
void solve() {
int n;
cin >> n;
int i;
set<int> s;
for (i = 2; i * i <= n; i++) {
if (n % i == 0 && !s.count(i)) {
s.insert(i);
n /= i;
break;
}
}
for (i = 2; i * i <= n; i++) {
if (n % i == 0 && !s.c... |
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 io
import os
from collections import Counter, defaultdict, deque
def solve(N, ):
ans = []
while len(ans) < 2:
for i in range(ans[-1] + 1 if ans else 2, int(N**0.5) + 1):
if N % i == 0:
ans.append(i)
N //= i
break
else:
... |
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 product(n):
a = int(min_divisor(2,n))
if a==n:
return False
else:
b = int(min_divisor(a+1,n/a))
if b==a or b==1:
return False
else:
c = int(n/(a*b))
if c==a or c == b or c==1:
return False
else:
... |
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 sovle():
n = int(input())
a = []
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
a.append(i)
n //= i
if len(a) == 2:
break
if len(a) == 2 and n not in a:
print('YES')
print(a[0], a[1], n)
else:
pri... |
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())):
n=int(input())
nd=n
count2=0
ar=[]
flag=True
spcount=0
while(n%2==0):
spcount+=1
n//=2
if(spcount<3 and spcount>=1):
count2+=1
ar.append(2)
elif(spcount<6 and spcount>=1):
count2+=2
ar.append(2)
ar.... |
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)... | #!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from collections import Counter
from io import BytesIO, IOBase
from math import gcd
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def... |
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())):
n=int(input())
k,j=2,0
a=[]
while(j<2 and k*k<n):
if(n%k==0):
a.append(k)
n=n//k
j+=1
k+=1
if(j!=2):
print("NO")
elif(a[1]!=n):
print("YES")
a.append(n)
print(*a)
else:
p... |
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 solve(n):
f = []
while (n % 2 == 0):
f.append(2)
n = n / 2
R = int(math.sqrt(n))
for e in range(3, R + 1, 2):
while (n % e == 0):
f.append(e)
n = n / e
if n != 1.0:
f.append(int(n))
return f
while t > 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;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, k = 2, a[3], q, c = 0;
cin >> n;
for (long long i = 2; i * i < n && c < 2; i++) {
if (n % i == 0) {
a[c++] = i;
n = n / i;
}
}
if (c != 2)
cout << "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)... | from math import sqrt
t = int(input())
for j in range(t):
n = int(input())
m = 0
bul_1 = False
bul_2 = False
i = 2
while i <= int(sqrt(n)):
if n % i == 0:
if bul_1:
bul_2 = True
if i != n // i:
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)... | from functools import reduce
def factors(n):
return sorted(list(set(reduce(list.__add__,
([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))
for _ in range(int(input())):
N = int(input())
r = factors(N)
len_r = len(r)
tmp = 0
if len_r - 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 i in range(t):
n=int(input())
original=n
a=set()
i=2
a2=0
b2=0
for i in range(2,int(math.sqrt(n))+1):
if n%i==0:
a.add(i)
n//=i
a2=i
break
for i in range(2,int(math.sqrt(n))+1):
if n%i==0 and 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 getSmallestFactor(n,d):
for i in range(2,int(n**0.5)+1):
if i not in d and n%i==0:
return i
return -1
t = int(input())
for _ in range(t):
n = int(input())
sm1 = getSmallestFactor(n,{})
if sm1!=-1:
sm2 = getSmallestFactor(n//sm1,{sm1})
sm3 = n//(sm1*sm2)... |
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 countDivisors(n) :
cnt = 0
for i in range(1, (int)(math.sqrt(n)) + 1) :
if (n % i == 0) :
# If divisors are equal,
# count only one
if (n / i == i) :
cnt = cnt + 1
else : # Otherwise count both
... |
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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Maij
{
public static void main(String[] args)
{
new Thread(null, new Runnable() {
public void run() {
solve();
}
... |
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 q in range(t):
n=int(input())
i1=1
j1=1
k1=1
q=int(n**0.5)
for i in range(2,q):
if n%i==0:
i1=i
break
if i1!=1:
n=n//i1
for j in range(i1+1,q):
if n%j==0:
j1=j
break
if j1!=... |
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>
int main() {
int t, n, m, s, s1, i, j, p;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
s = pow(n, 1.0 / 3);
p = 0;
for (i = 2; i <= s + 1; i++) {
if (n % i != 0) continue;
m = n / i;
s1 = sqrt(m);
for (j = i + 1; j <= s1; j++)
if (m % 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)... | 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
#print(l)
if tmp == 2 and n > l[1]:
print("YES")
l[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 bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in fi... |
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)... | # cook your dish here
t = int(input())
while t>0:
t -= 1
n = int(input())
cuben = int(n**(1.0/3))
a,b,c = 0,0,0
ispossible = False
for i in range(2,cuben+1):
if n%i==0:
num = int(n/i)
sqn = int(num**(1.0/2))
for j in range(i+1,sqn+1):
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.util.*;
import java.util.Collections;
public class S96{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
if(isprime(n)==true){
System.out.println("NO");
}
else{
ArrayList<Integer> al=ne... |
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 as m
n = int(input())
for _ in range(n):
a = int(input())
v=[]
for i in range(2,int(m.sqrt(a))+1):
if a%i==0 and i!=a//i:
z = a//i
for j in range(i+1,int(m.sqrt(z))+1):
if z%j==0 and j!=z//j:
a = 0
v.append([i,j,z//j])
break
if a==0:
break
if a==0:
print("YES")
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)... | t=int(input())
for i in range(t):
n=int(input())
arr=[]
i=2
while len(arr)<2 and i*i<=n:
if n%i==0:
arr.append(i)
n=n//i
i+=1
if n not in arr and len(arr)==2:
print("YES")
print(*arr,end=" ")
print(n)
else:
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)... | t = int(input())
def fd(n):
a = []
for i in range(2, 1+int(n**0.5)):
if n%i == 0:
a.append(i)
a.append(n//i)
return list(set(a))
for _ in range(t):
n = int(input())
found = False
d = fd(n)
for i in d:
tt = fd(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)... | from collections import deque
import sys
def inp():
return sys.stdin.readline().strip()
for _ in range(int(inp())):
n=int(inp())
i=2
fac=set()
while i*i<=n:
if n%i==0:
x=n//i
fac.add(i)
fac.add(x)
i+=1
fac=sorted(fac)
if len(fac)<3:
... |
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())):
n=int(input())
a=[]
i=2
while i*i<=n:
if n%i==0:
a.append(i)
if n//i!=i:a.append(n//i)
i+=1
flag=0
for i in range(len(a)):
for j in range(i+1,len(a)):
for k in range(j+1,len(a)):
if a[i]*a[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 javax.print.attribute.standard.PrinterMessageFromOperator;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
new Main().run();}
static int groups = 0;
static int[] fa;
... |
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 i in range(int(input())):
n=int(input())
d=2
a=[]
while len(a)<2 and d*d<n:
if n%d==0:
a.append(d)
n//=d
d+=1
if len(a)<2:
print("NO")
else:
print("YES")
print(n,*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)... | t = int(input())
for i in range(t):
n = int(input())
a = n
for i in range(2, 35000):
if n % i == 0:
a = i
break
n //= a
b = n
for i in range(2, 35000):
if n % i == 0 and a != i:
b = i
break
n //= b
if n == 1 or n == a or 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 math
def GetNumber(start, n, number, count):
if count == 1 and n >= start:
number += (str(n))
print("YES")
print(number)
return
for i in range(start, int(math.sqrt(n)) + 1):
if n % i == 0:
number += (str(i)+" ")
count -= 1
GetN... |
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 num_divisors(n):
div=[]
for i in range(2,int(math.sqrt(n))):
if n%i==0:
div.append(i)
for j in range(i+1,int(math.sqrt(n/i))+1):
if (n/i)%j==0:
if (n/i)!=j*j:
div.extend([j,n/(i*j)])
print("YES")
print(" ".join([str(round(d)) for d in div]))
return
div.remo... |
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--) {
int n;
cin >> n;
vector<int> vp;
for (int i = 2; i <= sqrt(n); i++) {
while (n % i == 0) {
vp.push_back(i);
n /= i;
}
}
if (n > 1) {
vp.push_back(n);
}
sort(v... |
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())):
n=int(input())
ok=False
for i in range(2,int(n**0.5)+1):
if n%i==0:
p=n//i
if p==i:
continue
for j in range(2,int(p**0.5)+1):
if p%j==0:
if j==i or j==p//j or p//j==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)... |
//package codeforce;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;
public class product {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(Syst... |
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 codeforces1294C
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int t= s.nextInt();
while(t-->0)
{
int m = s.nextInt(),n=m,i,a=1,b=1;
for(i=2;i*i<=m;i++)
{
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)... | from math import floor,sqrt
for _ in range(int(input())):
n=int(input())
if n<=10:
print("NO")
else:
l=[]
c=0
for i in range(2,floor(sqrt(n))+1):
if c==2:
break
if n%i==0:
l.append(i)
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)... | for i in range(int(input())):
n = int(input())
d = []
cnt = 2
c = 1
a,b,c = 1,1,1
for i in range(2,int(n**0.5)+1):
if n%i==0:
d.append(i)
if len(d)<=2:
print("NO")
c=0
else:
a = d[0]
for j in range(len(d)):
b = d[j]
c = n//(a*b)
if a*b*c==n and a<b<c:
print("YES\n",a,b,c)
c = 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 get_fac(n, cr, ml):
for i in range(2, ml+1):
if not cr[i]: continue
if n % i == 0:
cr[i] = False
return i
else:
for j in range(1,ml//i):
cr[i*j] = False
for _ in range(t):
n = int(input())
ml = ... |
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())
while t:
n = int(input())
flag = 1
arr= []
i=2
while i*i<n:
if n%i==0 and i not in arr:
arr.append(i)
n//=i
break
i+=1
i=2
while i*i<n:
if n%i==0 and i not in arr:
arr.append(i)
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
x=int(input())
for _ in range(x):
n=int(input())
c=0
lol=set()
f=0
for i in range(2,int(math.sqrt(n))+1):
if n%i==0:
k=i
while n%k==0:
n//=k
lol.add(k)
c+=1
k*=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;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v;
int m = n;
for (int i = 2; i <= sqrt(m); i++) {
if (m % i == 0) {
v.push_back(i);
m /= i;
break;
}
}
for (int i = 2; i <= sqrt(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)... | d = int(input())
ans = [[0]*3]*d
for i in range(d):
n = int(input())
k = int(n**(1/3))+1
f = True
j = 2
while j<k and f:
if n%j == 0:
l = n//j
x = j
while x<int(l**0.5)+1 and f:
x+=1
if l%x == 0 and x!=l//x and j!=l//x:
... |
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 affichage(L):
for i in range(len(L)):
L[i]=str(L[i])
return(' '.join(L))
t=int(input())
for i in range(t):
n=int(input())
n1=n
nb=0
x=int(n**0.5)
X=[]
for i in range(2,x+1):
if n%i==0:
n=n//i
X.append(i)
nb+... |
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
for _ in range(int(input())):
n = int(input())
facs = []
i = 2
x = n
while i <= int(math.sqrt(x)) and len(facs) < 2:
if n % i == 0:
facs.append(i)
n = n // i
i += 1
if n not in facs and n > 1:
facs.append(n)
if len(facs) == 3:
... |
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_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
map<long long, long long> cn;
set<long long> fac;
while (t--) {
fac.clear();
cn.clear();
long long n;
cin >> n;
long long temp = n;
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)... | import sys
from math import ceil, sqrt
t = int(sys.stdin.readline())
def factor(n):
pf = {}
maxp = min(n - 1, ceil(sqrt(n)))
nf = n
for p in range(2, maxp + 1):
if nf == 1:
break
while nf % p == 0:
nf //= p
if p in pf:
pf[p] += 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)... | t=int(input())
for q in range(t):
n=int(input())
c=[]
i=2
while len(c)<2 and i*i<n:
if n%i==0:
c.append(i)
n//=i
i+=1
if len(c)==2 and n not in c:
print('YES')
print(*c,n)
else:
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)... | import sys
I=sys.stdin.readline
ans=""
for _ in range(int(I())):
n=int(input())
fac=[]
for i in range(2,int(n**.5)):
if n%i==0:
fac.append((i,n//i))
break
if len(fac)!=0:
x=fac[0][1]
for i in range(2,int(x**.5)+1):
if x%i==0 and i!=fac[0][0] and 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)... | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException{
//0-1 Knapsack Problem
FastScanner fs = new FastScanner();
int test = fs.nextInt();
while(test-->0) {
int n = fs.nextInt();
ArrayList<Integer> f = new ArrayList<Integer>();
for... |
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)... |
c = int(input())
def handleCase(n):
cap = int(n ** 0.40) + 1
for i in range(2, cap):
if n % i == 0:
q = n // i
for j in range(i + 1, int(q ** 0.5) + 1):
if q % j == 0 and not q == j * j:
return str(i) + ' ' + str(j) + ' ' + str(n // i // 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)... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int test;
cin >> test;
while (test--) {
long long int n;
cin >> n;
long long int a = 0, b = 0;
for (long int i = 2; i * i <= n; i++) {
if (n % i == 0) {
a = i;
n = 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())
for m in range(t):
n= int(input())
flag= 0
u= int(pow(n,1/3))
i=2
while i<u+1:
if(n%i==0):
v= n/i
f= int(pow(v,1/2))
j= i+1
while j<f+1:
if(v%j==0):
v=v/j
flag=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)... | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
long long t;
cin >> t;
while (t--) {
long long n, a, b, bit1 = 0, bit2 = 0;
cin >> n;
for (long long i = 2; i * i <= n; i++)
if (n % i == 0 && i != n / i) {
a = i;
b = n / i;
bit1++;
break;
}
... |
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 factorization(num):
pn = []
while num % 2 == 0:
pn.append(2)
num //= 2
while num % 3 == 0:
pn.append(3)
num //= 3
fg = False
for i in range(5, int(num ** 0.5) + 1, 6):
if fg:
if i > int(num ** 0.5):
break
fg = False
... |
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
input = sys.stdin.readline
def factors(n):
ret = set()
for i in range(2, int(n**.5) + 1):
if n%i == 0:
ret.add(i)
ret.add(n//i)
return ret
def solve(n):
for i in range(2, int(n**.5)+1):
if n%i == 0 and i != n//i:
a, b = i, n//i
fa, fb = factors(a), factors(b)
# option 1
if len(fa)... |
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 solve(n):
a, b, c = None, None, n
i = 2
while c >= 2 and i * i < c:
if c % i == 0:
c //= i
if a is None:
a = i
elif c >= 2:
return a, i, c
i += 1
raise ValueError()
for T in range(int(input())):
try:
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)... | R = lambda:map(int, input().split(" "))
from math import sqrt
def divs(n):
a, b, c = 2, 2, 2
while a <= sqrt(n):
if n % a == 0:
n //= a
break
a += 1
b = a + 1
while b <= sqrt(n):
if n % b == 0:
c = n // b
if c == a or c == b:
... |
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 x in range(t):
n=int(input())
i=2
a=[]
while(len(a)<2 and i*i<n):
if n%i==0:
n=n//i
a.append(i)
i=i+1
if len(a)==2 and n not in a:
print("YES")
print(n,*a)
else:
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)... | import math
def primeFactors(n):
d = {}
while n % 2 == 0:
try:
d[2]+=1
except:
d[2]=1
n = n // 2
for i in range(3, int(math.sqrt(n))+1, 2):
while n % i == 0:
try:
d[i]+=1
except:
d[i]=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)... | for t in range(int(input())):
n = int(input())
try:
a = next(i for i in range(2, int(n**.5)+1) if n%i == 0)
n //= a
b = next(i for i in range(a+1, int(n**.5)+1) if n%i == 0)
c = n // b
if c <= b:
raise
print('YES')
print(a, b, n//b)
except:
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)... | def read():
n = int(input())
return n
def first_factor(n, from_factor):
for i in range(from_factor, int(n ** 0.5) + 1):
if n % i == 0:
return i
return None
def solve(n):
result = [0] * 3
from_factor = 2
for i in range(2):
d = first_factor(n, from_factor)
... |
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
range = xrange
input = raw_input
t = int(input())
for _ in range(t):
n = int(input())
fac = []
i = 2
while i * i <= n:
while n % i == 0:
fac.append(i)
n //= i
i += 1
if n > 1:
fac.append(n)
fac.reverse()
a = fac.pop()
b ... |
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())
c = 0
x = []
_n = n
end = int(n ** 0.5) + 1
for i in range(2, end):
if _n % i == 0:
c += 1
_n //= i
x.append(i)
if c >= 2:
break
if c >= 2 and not _n in x:
... |
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 solution(s):
nums = []
i = 2
while len(nums) < 2 and i ** 2 <= s:
if s % i == 0 and i not in nums:
nums.append(i)
s //= i
i += 1
if s not in nums and len(nums) == 2:
print("YES")
print(*nums, s)
else:
print("NO")
t = int(input())
while t > 0:
t -= 1
s = int(input())
solution(s)
|
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)... | z,zz=input,lambda:list(map(int,z().split()))
zzz=lambda:[int(i) for i in stdin.readline().split()]
szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
fro... |
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 os
import math
def f(n):
result = []
now = 2
while len(result) < 2 and now < math.sqrt(n):
if n % now == 0:
result.append(now)
n //= now
now += 1
if len(result) == 2 and n not in result:
return f"YES\n{result[0]} {result[1]} {n}"
else:
... |
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 isprime(n):
if n==1:
return False
if n==2:
return True
for x in range(2,int(math.sqrt(n))):
if n%x==0:
return False
return True
def issquare(n):
if int(math.sqrt(n))*int(math.sqrt(n)) == n:
return True
else:
return False
def solve(n):
for i in range(2,int(math.sqrt(n))):
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)... | import math
def divisors(n):
divs = list()
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
divs.extend([i, n // i])
return list(sorted(set(divs)))
def valid(first, second, third, result):
return third > 1 and third != first and third != second and first * second * third ... |
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 sqrt
for i in range(t):
number=int(input())
l=[]
for i in range(2,int(sqrt(number))+1):
if number%i==0:
for j in range(2,int(sqrt(number//i))+1):
if (number//i)%j==0 and j!=i and (number//i)//j not in[i,j]:
l.append(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())
for i in range(t):
n = int(input())
arr = []
fact = 2
flag = 0
while fact < (n//fact):# and len(arr) < 3:
if n % fact == 0:
n = n//fact
arr.append(fact)
if len(arr) == 2:
arr.append(n)
flag = 1
break
fact += 1
if flag:
print("YES")
print(*arr)
else:
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)... | for _ in range(int(input())):
n=int(input())
r=int(n**0.5)+1
ans=[]
for i in range(2,r):
if n%i==0:
n//=i
ans.append(i)
if len(ans)==2:break
if len(ans)==2:
if n in ans:print('NO')
else:
print('YES')
print(*ans, 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)... | #include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long a = 0, b = 0, c, d, e, f = 0, l, g, m, n, k, i, j, t, p, q;
cin >> t;
while (t--) {
cin >> n;
f = 0;
v.clear();
for (i = 2; f < 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)... | import sys
import math
import itertools
import functools
import collections
import operator
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def wr(arr): return ' '.join(map(str, arr))
def revn(... |
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.lang.*;
public class Cf1294C {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t,n,i,j,k,p,q,r;
t=sc.nextInt();
while(t>0) {
p=0;
q=0;
r=0;
n=sc.nextInt();
for(i=2;i<(int)Math.sqrt(n);i++) {
if(n%i==0) {
p=i;
break;
... |
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 three_nums(n):
ret = []
i_max = int(n ** 0.5 + 0.5)
remainder = n
cnt = 0
for i in range(2, i_max + 1):
if remainder % i == 0:
ret.append(i)
remainder //= i
i_max = int(remainder ** 0.5 + 0.5)
cnt += 1
if cnt == 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())
while t > 0:
n=int(input())
s=set()
aqn=n
for i in range(2,int(math.sqrt(n))+1):
if(aqn%i ==0):
s.add(i)
aqn=int(aqn/i)
if(len(s)==2):
break
s.add(aqn)
if(len(s)==3):
print("YES")
for i in s:
... |
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())):
t = n = int(input())
m = []
j = 2
while len(m)<2 and j*j<t:
if n%j == 0:
m.append(j)
n //= j
j += 1
if len(m)==2 and n>=j:
print("YES")
print(m[0], m[1], n)
else:
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)... | import math
def solve():
n = int(input())
a = 0
b = 0
for i in range(2, math.ceil(math.sqrt(n))):
if n % i == 0:
a = i
n //= a
break
for i in range(2, math.ceil(math.sqrt(n))):
if n % i == 0 and i != a:
b = i
n //= b
... |
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 main():
t = int(input())
out_lst = []
if t <=100 and t >= 1:
for i in range(t):
n = int(input())
div_n = n
lst = []
n_rang = int(math.sqrt(n))
for j in range(2,n_rang):
if div_n % j == 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())
for i in range(t):
n=int(input())
a=[]
for i in range(2,math.ceil(math.sqrt(n))+2):
if n%i==0:
n//=i
a.append(i)
if len(a)==2:
break
else:
print('NO')
continue
if n==1 or n==a[0] or n==a[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)... | for _ in " "*int(input()):
a=int(input());b=[];i=2
while(len(b)<2 and i*i<a):
if a%i==0 and i not in b:b+=[i];a//=i;i=2
else:i+=1
if len(b)==2 and a>1:
print("YES");print(*b,a)
else: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)... | for _ in range(int(input())):
n = int(input())
a = []
for i in range(2, int(n**(1/2) + 1)):
if(n%i==0):
n = n//i
a.append(i)
if(len(a)==2):
if(n not in a):
a.append(n)
break
else:
break
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)... | for _ in range(int(input())):
num = int(input())
list_of_nums = [1]
for i in range(2, int(pow(num, 1/3)+1)):
if num % i == 0:
num = num // i
list_of_nums.append(i)
break
# print(list_of_nums)
for i in range(2, int(pow(num, .5))+1):
if num % 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
for _ in range(int(input())):
n = int(input())
m = n
ans = False
l = []
for i in range(2,int(math.sqrt(n))):
if m % i == 0:
l.append(i)
m = m // i
if len(l) == 2:
if l[1] != m and l[0] != m:
ans = True
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.