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)...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n; cin >> n; for (long long int i = 0; i < n; i++) { long long int a, x; cin >> a; x = a; vector<int> v; for (long long int i = 2; i <= sqrt(a); i++) { 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)...
for _ in range(int(input())): n=int(input()) a=b=c=1 for i in range(2,int((n**0.5)+1)): if n%i==0: a=i break if a==1: print('NO') continue x=n//a for i in range(2,int(((x)**0.5)+1)): if x%i==0 and i!=a: b=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)...
""" This template is made by Satwik_Tiwari. python programmers can use this template :)) . """ #=============================================================================================== #importing some useful libraries. import sys import bisect import heapq from math import * from collections import Cou...
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()) abc = set() for i in range(2, int(n**0.5)+1): if n % i == 0: if len(abc) == 0: abc.add(i) n = n//i else: if i != n//i and n//i != 1: abc.add(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 _ in range(t): n= int(input()) import math temp = int(math.sqrt(n)) done = 0 for i in range(2,temp+1): if n%i == 0: a = i for j in range(2,int(math.sqrt(a))+1): if a%j == 0 and a/j != a: x = 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 libraries for input/ output handling # on generic level import atexit, io, sys # A stream implementation using an in-memory bytes # buffer. It inherits BufferedIOBase. buffer = io.BytesIO() sys.stdout = buffer # print via here @atexit.register def write(): sys.__stdout__.write(buffer.get...
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; long long n, m, ni, mi; long long cn; string s; long long num[100005]; long long ok = false; deque<long long> v; map<string, bool> M; map<string, bool> MC; long long sch(long long a, long long b, long long c, long long i) { string s = to_string(a) + " " + to_string(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)...
////////////////////---------------------------SHUBHAM CHAUDHARI-------------------------------/////////////////////// import java.util.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int t=in.nextInt(); StringBuilder res=new StringBuild...
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 collections import itertools import sys from collections import defaultdict, Counter from math import sqrt, ceil input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return (int(input())) def inlt(): return (list(map(int, input().split()))) def insr(): 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)...
from math import sqrt n = int(input()) for i in range(n): f = int(input()) a = [] for j in range(2, int(sqrt(f))): if f % j == 0: a.append(j) f = f // j if len(a) == 2: break if len(a)==2 and a.count(f)==0: print("YES") print(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)...
'''input 3 1 2 3 4 5 6 ''' import math # Method to print the divisors def printDivisors(n) : list = [] # List to store half of the divisors a = [] x = n for i in range(2, int(math.sqrt(n) + 1)) : if (x % i == 0) : a.append(i) # i -= 1 x/=i if len(a)==2: p = 1 # for i in range(2,le...
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, floor t = int(input()) for _ in range(t): n = int(input()) if n < 24: print("NO") else: m = floor(sqrt(n)) + 1 d = 0 divs = [] for i in range(2, m): if n % i == 0: d += 1 divs.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)...
for _ in[0]*int(input()): n=int(input());a=['YES'];i=j=2 while j<4and i*i<n: if n%i<1:a+=i,;n//=i;j+=1 i+=1 print(*(a+[n],['NO'])[j<4][:4])
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 j in range(t): n = int(input()) a = 1 b = 1 c = 1 for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: a = i break m = n // a for i in range(a + 1, int(math.sqrt(m)) + 1): if m % i == 0: b = 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; double squrt(int64_t num) { double high = num, low = 0, mid; while (high - low > 0.00001) { mid = low + (high - low) / 2; if (mid * mid > num) { high = mid; } else { low = mid; } } return mid; } void solve() { int64_t num; cin >> num;...
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> #pragma GCC optimize("O3") using namespace std; int add(int a, int b) { long long x = a + b; if (x >= 1000000007) x -= 1000000007; if (x < 0) x += 1000000007; return x; } long long mul(long long a, long long b) { return (a * b) % 1000000007; } long long pw(long long a, long long 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)...
#include <bits/stdc++.h> using namespace std; const int MAX_N = -1; const int inf = 2e9 + 19; vector<long long> vec; void primeDiv(long long n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { while (n % i == 0) vec.push_back(i), n /= i; } } if (n) vec.push_back(n); } int main() { ios::sync_...
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()) dvdrs = [] passs = True if n < 24: print("NO") continue for k in range(2,n): if k*k*k > n: passs = False break if n%k == 0: dvdrs += [k] n = int(n/k) break if passs: for k in range(dvdrs[0]+1, n): if k*k > n: passs = Fal...
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 div(n): l = [] i = 2 while i <= math.sqrt(n): if (n % i == 0): if (n / i == i): l.append(int(i)) else: l.append(int(i)) l.append(int(n/i)) i = i + 1 l.sort() return l for _ in range(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)...
import java.util.*; import java.lang.Math; import java.io.* ; public class Account { class Pair { int key ; int val ; Pair(int key ,int val) { this.key = key ; this.val = val ; } int getKey() { return this.key ; } ...
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): li =[] while n % 2 == 0: li.append(2) #print (2) n = n//2 for i in range(3,int(math.sqrt(n))+1,2): while n % i== 0: ##print (i) li.append(i) n = n//i if n > 2: li.append(...
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; using ll = long long; using lli = long long int; using ld = long double; const int N = 2e5 + 5, inf = 2e9; bool valid(int a, int b, int c) { if (a == b || b == c || a == c) return false; return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.ti...
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 geek { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { int n = s.nextInt(); int a = 0; int b = 0; int c = 0; 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 sys from collections import defaultdict as dc import math from bisect import bisect, bisect_left,bisect_right input=sys.stdin.readline for _ in range(int(input())): n=int(input()) i=2 f=0 #p=math.sqrt(n) while(i<=math.sqrt(n)): if n%i==0: f=1 break 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)...
def prime(n): if n == 1: return [] if n == 2: return [2] i = 2 while i*i <= n: if n%i == 0: return prime(n//i)+[i] i += 1 return [n] for _ in range(int(input())): n = int(input()) a = sorted(prime(n)) if len(set(a)) >= 3: print("YE...
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 prod(li): p = 1 for i in li: p*=i return p def getAns(n): d = dict() while n % 2 == 0: if 2 in d.keys(): d[2] += 1 else: d[2] = 1 n//=2 for i in range(3, int(math.sqrt(n)) + 3, 2): while n % i == 0: if i in d.k...
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 string import math import collections def LeReseauLMD(n): orin = n a,b,c = 0,0,0 for a in range(2,math.floor(n**0.5)+1): if n%a==0: n //=a for b in range(2,math.floor((n)**0.5)+1): if n%b == 0 and b != a: """for c in range(2,math....
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 max6 = 1e6 + 6; map<int, int> rem; int e[max6], p[max6]; int main() { int tests; scanf("%d", &tests); for (int i = 1; i <= 1000000; ++i) e[i] = i; int sl = 0; for (int i = 2; i <= 1000000; ++i) if (e[i] == i) { p[++sl] = i; for (int j = 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 range(int(input())): i = 2 l = [] n = int(input()) size = 0 while(i*i<=n and size < 2): if(n % i == 0): l.append(i) n //= i size += 1 i += 1 if(size == 2 and (l[0]!=n and l[1]!=n)): print('YES') print(l[0],l[1],n) e...
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_ints(): return map(int, input().split()) def read_int(): return int(input()) def factors(n): factors_p = dict() twos = 0 while n % 2 == 0: n //= 2 twos += 1 if twos > 0: factors_p[2] = twos d = 3 while d * d <= n: p = 0 while n % d == 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, ceil t = int(input()) for _ in range(t): a = -1 b = -1 n = int(input()) i = 2 while i*i < n: if n % i == 0: a = i n //= a break i += 1 i = 2 while i*i < n: if n % i == 0 and i != a: b = 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)...
m=int(input()) for l in range(m): n=int(input()) q,t=int(n**.5)+1,0 for i in range(2,q): if n%i==0: a=n//i w=int(a**.5)+1 for j in range(2,w): if a%j==0: r=a//j if r!=j and j!=i and r!=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 m=1000000007 def fact(n): ans=1 for i in range(1,n+1): ans=((ans%m)*(i%m))%m return ans def power_2(n): ans=1 for i in range(n): ans=((ans%m)*(2))%m return ans for z in range(int(input())): n=int(input()) fin=int(math.ceil(n**(1/3))) cnt,i=0,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 sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep=" ") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(row...
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 t=int(input()) for i in range(t): x=int(input()) ar=[] l=0 a=1 b=1 c=1 ct=0 bl=False for j in range(2,int(x**(0.5))): if(x%j==0 and ct==0): a=j ct+=1 elif(x%j==0 and ct==1): temp=j 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)...
from sys import stdin, stdout import sys INF=1e9 import bisect def get_int(): return int(stdin.readline().strip()) def get_ints(): return map(int,stdin.readline().strip().split()) def get_array(): return list(map(int,stdin.readline().strip().split())) def get_string(): return stdin.readline().strip() def op(c): 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)...
for _ in range(int(input())): num = int(input()) list_of_nums = [1] for i in range(2, int(pow(num, .5)+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 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)...
'use strict' const problem = (n) => { for (let i = 2; i < Math.cbrt(n); i++) { if (n % i === 0) { n /= i; for (let j = i + 1; j < Math.sqrt(n); j++) { if (n % j === 0) return `YES\n${i} ${j} ${n/j}`; } } } return 'NO'; } let t = +readline...
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 my_def(x): a, b, c = 1, 1, 1 for j in range(2, int(x ** 0.5) + 2): while x % j == 0: if a == 1: a = j elif b == 1 or b == a: b *= j else: return (a, b, x) x //= j return (a, b, x) 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)...
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)...
from math import sqrt t=int(input()) for w in range(t): n=int(input()) c=0 ans=[] for i in range(2,int(sqrt(n))+1): if n==1 or c==2: break if n%i==0: ans.append(i) n=n//i c+=1 if c<2 or n==ans[1] or n==ans[0]: print("NO") el...
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 collections import Counter,defaultdict I =lambda:int(input()) M =lambda:map(int,input().split()) LI=lambda:list(map(int,input().split())) for _ in range(I()): n=I();i=2;a,b,c=-1,-1,-1 while i*i<=n: while n%i==0: n//=i if a==-1: a=i eli...
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; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); int flag, a, b, c; flag = 1; if (n % 2 == 0) { a = 2; flag = 0; } else for (a = 3; a * a * a <= n; a += 2) if (n % a == 0) { flag = 0; 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)...
import java.util.*; public class code { static int sqrt(int x) { for(int i=2; true; i++) { if(i*i==x) { return i; } if(i*i>x) { return i-1; } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=0; i<n; i++) { int a= 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)...
def find_multipliers(n): if n < 8: return None a = b = c = None for i in range(2, int(n**0.5 + 1)): if n % i == 0: a = i break if a is None: return None n /= a for i in range(2, int(n**0.5 + 1)): if (i != a) and (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)...
def Sieve(n): ret = [] divlis = [-1] * (n+1) flag = [True] * (n+1) flag[0] = False flag[1] = False ind = 2 while ind <= n: if flag[ind]: ret.append(ind) ind2 = ind ** 2 while ind2 <= n: flag[ind2] = False d...
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 int T; cin >> T; while (T--) { long long int n, k = 0, i, j, b, c, flag = 0, p = 0; cin >> n; vector<int> a; for (int i = 1; i <= sqrt(n); i++) { if (n % i == 0) { if (n / i == i) a.push_back(i); e...
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=[] a=2 m=n while a*a<=n: if(n%a==0): l.append(a) n=n//a break a+=1 b=2 while b*b<=n: if(n%b==0): if b not in l: l.append(b) n=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)...
t = int(input()) for i in range(t): N = int(input()) answer = [] F = 0 for i in range(2,int(N**0.5)+1): if N%i == 0: X = i Z = N//i for j in range(2,int(Z**0.5)+1): if Z%j==0: ANS1=Z//j if ANS1!=j and ANS...
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 bisect import bisect_left as bl from bisect import bisect_right as br import heapq import math from collections import * from functools import reduce,cmp_to_key import sys input = sys.stdin.readline # M = mod = 998244353 def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**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 java.io.*; import java.util.*; import static java.lang.Math.max; public class Main { public static void main(String[] args) throws IOException { run(); end(); } static void run() throws IOException { int t = nextInt(); while (t-- > 0) { solve(nextInt(...
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 factors(x): l=[] while(x>1): a=0 for i in range(2,int(math.sqrt(x)+1)): if(x%i==0): l.append(i) a=1 break if(a==0): l.append(x) break x=x//l[-1] return l t=int(input()) while(t...
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()) l = [] i = 2 c = 0 while(c < 2 and i*i < n): if(n % i == 0): l.append(i) n //= i c += 1 i += 1 #print(*l) if(c == 2 and n not in l): print('YES') print(*l, 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)...
# -*- coding: utf-8 -*- """ Created on Tue Feb 4 23:28:21 2020 @author: User """ import math n = int(input()) num = [] for i in range(n): num.append(int(input())) for x in num: flag = 0 counter = 0 y = int(math.sqrt(x)) for j in range(2,y+1) : if flag == 1 : break e...
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 //do not write package name here */ import java.util.*; import java.lang.*; import java.io.*; public class GFG { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) {int n=sc.nextInt();mm(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)...
#-------------Program-------------- #----Kuzlyaev-Nikita-Codeforces---- #-------------Round615------------- #---------------------------------- t=int(input()) for i in range(t): n=int(input()) a=[] for i in range(2,int(n**0.5)+2): if len(a)==2: a.append(n) 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)...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n = mint() a = [] nn = n for i in range(2,n+1): if i*i > n: break if n % i == 0: c = 0 while n % i == 0: n //= i if len(a) == 2: 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)...
#include <bits/stdc++.h> using namespace std; inline void setPrecision(int n) { cout.precision(n); } long long int INF = 1e10; int MOD = 1e9 + 7; inline bool same2(int x, int y, int z) { return (x == y) || (y == z) || (z == x); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt; cin...
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 _ in range(t): n=int(input()) raj=set() for i in range(2, math.ceil(math.sqrt(n))): if(n%i==0): raj.add(i) raj.add(n//i) flg=0 for i in raj: a=i dup=n//a andro=set() for j in range(2, math.ceil(math.sqrt(...
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 div(n, r): sq = math.sqrt(n) d = 1 for x in range(2, int(sq) + 1): if n % x == 0 and x != r: d = x break return d t = int(input()) for i in range(0, t): y = int(input()) a = div(y, 1) if a == 1: print("NO") continue 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 deliteli_chisla(cur): mas = [] ot = "NO" n = cur for i in range(2, math.ceil(cur ** 0.5)): if n % i == 0: mas.append(i) for i in range(len(mas)): del1 = mas[i] nn = n // del1 s = nn for j in range(i, len(mas)): nn = 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)...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a, b, c, c1 = 0; for (int i = 2; i < sqrt(n) + 1; i++) { if (n % i == 0) { if (c1 == 0) { a = i; c1++; n = n / i; } else if (c1 == 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 range(int(input())): n = int(input()) a = [] i=2 while(len(a)<2 and i*i <n): if n%i ==0: n=n//i a.append(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)...
t=int(input()) for i in range(t): n=int(input()) a=[] for j in range(2,int(n**0.5)+1): if(n%j==0): a.append(j) n=n/j break if(len(a)==1): for k in range(j+1,int(n**0.5)+1): if(n%k==0): a.append(k) n=int(n/k)...
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()) ans=list() for i in range(2,int(n**(2/3))+1): if len(ans) == 2: break if n%i==0: ans.append(i) n//=i if len(ans) == 2 and ans[1] < n: print('YES') print(*ans, n) else: pr...
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)): x=input() x=int(x) d=0 a,b,c=-1,-1,-1 p=x for j in range(2,int(math.sqrt(x))+1): if x%j==0: a=j x=x//j break if a!=-1: for j in range(a+1,int(math.sqrt(x))+1): if x%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)...
t = int(input()) for _ in range(t): n = int(input()) f = 0 for x in range(2, n): if x * x * x >= n: break for y in range(x + 1, n): #print(x, y) if x * y * y >= n: break if n % (x * y) == 0: f = 1 print("YES") print(x, y, n // (x * y)) break if f > 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> int main() { int t; std::cin >> t; for (; t > 0; t--) { long n; std::cin >> n; int i = 2; std::vector<int> primes; while (i * i <= n) { if (n % i == 0) { while (n % i == 0) { primes.push_back(i); 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)...
import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.Set; public class Main { private static long gcd(long a, long b) { return (a == 0 ? b : gcd(b % a, a)); } public static void main(Strin...
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 check(n): k=0 for i in range(2,int(sqrt(n+1))): if k==2 and n>=i: return a,b,n if k==3: return a,b,c if k<3 and n<i: return 'NO' if n%i==0: k+=1 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)...
# Python3 implementation of the approach from math import sqrt # Function to find the required triplets def findTriplets(x): # To store the factors fact = []; factors = set(); # Find factors in sqrt(x) time for i in range(2, int(sqrt(x))): if (x % i == 0): fact.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)...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 22 08:37:17 2020 @author: huynguyen """ def findTripple(n): res = [] for i in range(2,int(n**.5)+1): if n%i == 0: res.append(i) n//=i if len(res) ==2: break if n!=1: if res: ...
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 q = int(input()) for _ in range(q): n = int(input()) cnt = 0 save = [0] * 6 for i in range(2, int(sqrt(n)) + 2): if n % i == 0: cnt += 1 save[cnt] = i n = int(n/i) if cnt == 2: break if cnt < 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)...
#include <bits/stdc++.h> using namespace std; int main() { int t, i; long n, d, arr[2]; cin >> t; while (t--) { cin >> n; i = 0; for (d = 2; d * d < n && i < 2; d++) { if (n % d == 0) { arr[i++] = d; n /= d; } } if (i == 2) cout << "YES\n" << arr[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 x in range(t): n=int(input()) l=[] i=2 while len(l)<2 and n>i**2: if n%i==0: l.append(i) n=n/i i+=1 if len(l)==2 and n not in l: print('YES') print(*l,int(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 import os import time import collections from collections import Counter, deque import itertools import math import timeit import random ######################### # imgur.com/Pkt7iIf.png # ######################### def sieve(n): if n < 2: return list() prime = [True for _ in range(n + 1)] p = 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)...
#!/usr/bin/env python3 import math primes = [2] for n in range(3,math.ceil(math.sqrt(1e9)),2): is_prime = True sqrt_n = math.sqrt(n) for p in primes: if p > sqrt_n: break if n%p == 0: is_prime = False break if is_prime: primes.append(n) t =...
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)...
# -*- coding: utf-8 -*- """ Created on Wed Jan 22 19:40:08 2020 @author: DELL """ import math # A function to print all prime factors of # a given number n def primeFactors(n): li=[] # Print the number of two's that divide n while n % 2 == 0: li.append(2) n = 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)...
for _ in range(int(input())): n=int(input()) t=pow(n,0.5)+3 l=[] co=0 i=2 while i<t: if n%i==0: n=n//i l.append(i) else: i+=1 # print(l) if n!=1: l.append(n) flag="YES" t=len(l) if t>=3: a=l[-1] l.pop(-1) b=l[-1] l.pop(-1) if a==b: b=b*l[-1] l.pop(-1) c=1 for i in l: c=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 java.util.*; public class Product_of_Three_Numbers { public static void main(String args[]) { Scanner ob=new Scanner(System.in); int t=ob.nextInt(); while(t-->0) { int n=ob.nextInt(); int a=0,b=0; for(int i=2;i*i<n;i++) { if(n%i==0) { n/=i; if(a==0) a=i; else{ b=i; break; } } } if(a!=0 && b!=0 && n>b) { System.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 _ in range(t): n = int(input()) li = [] i = 2 while i*i<n: if n%i==0: li.append(i) n/=i if len(li)==2: break i+=1 if len(li)!=2 or n in li: print('NO') else: print("YES") print(li[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 factorial from collections import Counter from sys import stdin def RL(): return map(int, stdin.readline().rstrip().split() ) def comb(n, m): return factorial(n)/(factorial(m)*factorial(n-m)) if n>=m else 0 def perm(n, m): return factorial(n)//(factorial(n-m)) if n>=m else 0 def mdis(x1, y1, x2, y2): r...
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)...
# Python program to print prime factors import math # a given number n def prime(n): a= []# Print the number of two's that divide n while n % 2 == 0: a.append(2) n = n / 2 # n must be odd at this point # so a skip of 2 ( i = i + 2) can be used for i in range(3,int(math.sqrt(n))+1,2): # wh...
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 _ in range(t): n = int(input()) d = [] while n % 2 == 0: d.append(2) n //= 2 for i in range(3, (int(math.sqrt(n)) + 1), 2): while n % i == 0: d.append(i) n //= i if n > 2: d.append(n) if len(d) < 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 math as mt n = int(input()) i = 0 while i < n: case = int(input()) n1 = case a, b, c = 1, 1, 1 divisor = [] for p in range(2, mt.ceil(mt.sqrt(case + 1))): if len(divisor) == 2: divisor.append(int(n1 / (divisor[0] * divisor[1]))) break elif case % p == 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() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> q; while (q--) { cin >> n; vector<int> res; for (int i = 2; res.size() < 2 && i * i < n; ++i) { if (n % i == 0) { res.push_back(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)...
def IsPrime(n): d = 2 while d * d <= n and n % d != 0: d += 1 return d * d > n t = int(input()) ans = [] for j in range(t): n = int(input()) divs = [] i = 2 while i*i <= n: if n % i == 0: x = n // i u = i + 1 while u*u <= x: 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)...
import java.io.*; import java.util.*; import java.lang.Math.*; public class CodeForces615C { public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.valueOf(br.readLine()); for (int i = 0;i<t ;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.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = Integer.parseInt(sc.next()); for(int i = 0; i < t; i++){ int n = 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)...
from sys import stdin, stdout from collections import defaultdict import math rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() def main(): cases = int(input()) for line in stdin: n = int(line) ans = [] f1 = 2 while f1 <= math.sqrt(n): if n % f1 == 0: ans.append(f1) break f1...
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 ceil, sqrt n = int(input()) for i in range(n): num = int(input()) ans = [] for mult in range(2, ceil(sqrt(num))): #print('Try ', mult,' for ', num) if num < mult: break if num % mult == 0: ans.append(mult) num = num / mult ...
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.*; import java.io.*; public class Codeforces { static FastReader sc=new FastReader(); static PrintWriter out=new PrintWriter(System.out); static long mod=1000000007; public static void main (String[] args) throws java.lang.Exception { // your code goes here // StringBuf...
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 # coding: utf-8 # In[7]: import math def divisor(n): for i in range(2,int(math.sqrt(n))+1): if n%i==0: k=n//i for j in range(2,int(math.sqrt(k))+1): if j!=i and k%j==0: t=k//j if t!=i and t!=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 java.io.*; import java.util.*; import java.math.*; public class S{ static class Pair implements Comparable<Pair>{ int a; int b; public Pair(int x,int y){a=x;b=y;} public Pair(){} public int compareTo(Pair p1){ if(a == p1.a) return b - p1.b; return a - p1.a; } } stati...
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 q; cin >> q; for (int i = 0; i < q; ++i) { int 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...
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 pm(n): arr = [] while(n%2==0): arr.append(2) n//=2 for i in range(3,int(pow(n,0.5))+1,2): while n%i==0: arr.append(i) n//=i if n>2: arr.append(n) return arr tc = int(input()) for ii in range(tc): n = int(input()) arr = pm(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)...
for _ in range(int(input())): n=int(input()) l=[];i=2 while len(l)<2 and i*i<n: if n%i==0:l.append(i);n//=i; i+=1 if len(l)==2 and n not in l:print("YES");print(*l,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 from functools import reduce t = int(input()) for _ in range(t): n = int(input()) m = n sqrt_n = int(math.sqrt(n)) res = [] for i in range(2, sqrt_n): if n == 1: break while n > 1 and n % i == 0: res.append(i) n //= i if n > 1: res.append(n) if len(res) < 3: print('NO') elif len(r...
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 # print = lambda x: stdout.write(x) # input = stdin.readline from math import sqrt #Ref: Geeksforgeeks def primeFactors(n): arr = [] # Print the number of two's that divide n while n % 2 == 0: arr.append(2) n = n // 2 # n must be odd at this point # ...
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 factor(n): s = int(sqrt(n)) rLst = [1, n] for i in xrange(2, s+1): if n%i==0: rLst.append(i) if n//i != i: rLst.append(n//i) rLst = list(set(rLst)) rLst.sort() return rLst from sys import stdin raw_input = lambda: stdin.readline().rstrip() input = lambda: int(raw_input()) I=...