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)...
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**2 <= n: if n % f1 == 0: ans.append(f1) break f1 += 1 ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math def primefactorisation(n): p=[] while(n%2==0): n//=2 p.append(2) i=3 while(i<=math.sqrt(n)): while(n%i==0): n//=i p.append(i) i+=2 if n>2: p.append(n) return p for _ in range(int(input())): n=int(input()) A=prim...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int t = 1; cin >> t; while (t--) { long long int n; cin >> n; vector<long long int> v; long long int x = n; while (n % 2 == 0) { v.push_back(2); ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
from collections import Counter, defaultdict from sys import stdin, stdout raw_input = stdin.readline for t in xrange(input()): n=input() l=[] f=0 for i in xrange(2,min(n+1,10001)): if n%i==0: l.append(i) n/=i if len(l)==2 and n not in l and n>1: f=1 ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math from itertools import permutations def divisores(n): large_divisors = [] for k in range(1, int(math.sqrt(n) + 1)): if(n % k == 0): yield k if(k*k != n): large_divisors.append(n//k) for d in reversed(large_divisors): yield d t = 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 collections class Solution: def solve(self, n): used = set() a = 2 while a*a <= n: if n % a == 0 and a not in used: used.add(a) n //= a break a += 1 b = 2 while b*b <= n: if 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 for _ in range(int(input())): n = int(input()) flag = False if n < 24: print('NO') elif n == 24: print('YES') print(2, 3, 4) else: for i in range(2, int(math.sqrt(n)) + 1): 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)...
#include <bits/stdc++.h> using namespace std; bool test(void) { long long N; scanf("%lld", &N); long long u = N; vector<pair<long long, int>> A; for (long long i = 2; i * i <= u; ++i) { int q = 0; while (u % i == 0) { ++q; u /= i; } if (q) { A.push_back({i, q}); } } 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 for _ in range(int(input())): n = int(input()) t = n a1 = [] while n % 2 == 0: a1.append(2), n = n / 2 for i in range(3,int(math.sqrt(n))+1,2): while n % i== 0: a1.append(int(i)), n = n / i if 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)...
t = int(input()) for qwe in range(t): # n1 = int(f.readline()) n1 = int(input()) flag = False for i1 in range(2, int(n1**0.5) + 1): if n1 % i1 == 0: a = i1 n2 = n1 // i1 for i2 in range(2, int(n2**0.5) + 1): if n2 ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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, arr[10]; cin >> n; int cnt = 0; for (int i = 2; i < sqrt(n); i++) { if (n % i == 0 && ((n / i) != i)) { arr[0] = i; n = n / i; cnt = 5; break; } } 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)...
#Codeforces - Product of Three Numbers t = int(input()) while t != 0: n = int(input()) i = 2 result = 'NO' while i * i * i < n: if n % i == 0: j = i + 1 while j * j < int(n/i): if n % (i * j) == 0: result = '{} {} {}'.format(i, j, int(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)...
ans="" for _ in range(int(input())): n=nn=int(input()) l1=[]; i=2 while len(l1)<2 and i*i<=nn: if n%i==0: l1.append(i); n//=i i+=1 if len(l1)<2 or l1[1]==n or l1[0]==n: ans+="NO\n" else: ans+="YES\n"; ans+=f"{l1[0]} {l1[1]} {n}\n" print(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)...
import math for _ in range(int(input())): n=int(input()) l=[] x=n for i in range(2,int(math.sqrt(n))+1): if(len(l)<2): if(x%i==0): l.append(int(i)) x/=i else: break if((x not in l) and (len(l)==2)): 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)...
import sys sys.setrecursionlimit(10**9) import atexit import io from collections import defaultdict, Counter _INPUT_LINES = sys.stdin.read().splitlines() input = iter(_INPUT_LINES).__next__ _OUTPUT_BUFFER = io.StringIO() sys.stdout = _OUTPUT_BUFFER @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.ge...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 = int(input()) divs = [] for i in range(2, int(n**0.5) + 2): if n % i == 0: n //= i divs.append(i) if len(divs) == 2: if n > divs[1]: print ("YES") print (*divs, n) 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)...
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; set<int> values; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { values.insert(i); n /= i; break; } } for (int i = 2; i * i <= n; i++) { if (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 for _ in range(int(input())): n = int(input()) dic = {} x = n if x%2==0: dic[2] = 0 while x%2==0: x//=2 dic[2] += 1 for i in range(3,int(math.sqrt(x))+1,2): if x%i==0: dic[i] = 0 while x%i==0: x//=i dic[i] += 1 if x>2: dic[x] = 1 # print(dic) if len(dic)==3: print('Y...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
#include <bits/stdc++.h> using ll = long long; using namespace std; const int N = 1e6 + 1, mod = 1e9 + 7; int t; int main() { cin.tie(0)->sync_with_stdio(0); cin >> t; while (t--) { int n; cin >> n; vector<int> divisors; int d = n, s = sqrt(n); for (int i = 2; i <= s; i++) { if (d % 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())): n=int(input()) a=b=c=1 for i in range(2,int(n**0.5)+1): if(n%i == 0): a=i n//=i break for i in range(2,int(n**0.5)+1): if(n%i == 0): if(i!=a): b=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 java.io.*; import java.util.*; import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Math.abs; import static java.lang.System.exit; public class Main { static BufferedReader in; static PrintWriter out; ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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()) fin=[] for i in range(2,40000): if(n%i==0): n=n//i fin.append(i) break if(len(fin)==0): print("NO") else: for i in range(2,40000): if(n%i==0 and i!=fin[0] ): n=n//...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
def p3n(cur): j = 2 while j * j <= cur: if cur % j == 0: # print(cur, j) oth = cur // j k = 2 while k * k <= oth: if oth % k == 0 and j != k != oth // k != j: print('YES') print(j, k, oth // 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 math for _ in range(int(input())): n = int(input()) a = -99 t = 0 if(n < 24): print("NO") else: for i in range(2, (int)(math.sqrt(n)) + 1): if(n%i == 0): if(a > 0): if(n%(i*a) == 0): if(a != i) 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)...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { long long n, f = 0; cin >> n; long long i = 2; while (i * i < n) { if (n % i == 0) { f = 1; 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; int main() { int t; cin >> t; int n; while (t--) { cin >> n; vector<int> v; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); n /= i; } if (v.size() == 2) break; } if (n != 1) v.push_back(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 for i in range(int(input())): q=int(input()) k=[] t=0 for i in range(2,int(math.sqrt(q))+1): if q%i==0: q=q//i t=1 k.append(str(i)) break if t==1: for i in range(2,int(math.sqrt(q))+1): if q%i==0 and (str(i) not ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
t=int(input()) for _ in range(t): n=int(input()) a=[] append=a.append for i in range(2,int(n**0.5)+1): if(n%i==0): append(i) n=n//i if(len(a)==2): if n!=1: append(n) break a=list(set(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)...
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw= new PrintWriter(System.out); int t= Integer.parseInt(br.readLine()); for (in...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math t = int(input()) for _ in range(t): n = int(input()) nn = n fact = dict() i = 2 while i <= math.sqrt(nn): if n % i == 0: n //= i try: fact[i] += 1 except: fact[i] = 1 else: i += 1 if 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; using vi = vector<long long int>; using vvi = vector<vi>; using vb = vector<bool>; using vc = vector<char>; using vs = vector<string>; using vld = vector<long double>; using pii = pair<long long int, long long int>; using psi = pair<string, long long int>; using pci = pair<...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math from functools import reduce t = int(input()) for cas in range(t): n = int(input()) ans = [] m = n sqrt_n = int(math.sqrt(m)) for i in range(2, sqrt_n): cal = 0 if n == 1: break while n % i == 0 and n > 1: n //= i ans.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 pypy rr= lambda: input().strip() rri= lambda: int(rr()) rrm= lambda: [int(x) for x in rr().split()] def fact(n): res=[] for i in range(2, int(n**.5)+1): if n%i==0: res.append(i) res.append(n//i) if (int(n**.5)**2==n): res.pop() return res def sol(...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 input = lambda: stdin.readline().strip() for _ in range(int(input())): n = int(input()) a = [] for i in range(2,n//2): if(n%i==0): n //= i a.append(i) if(len(a)==2 or n<i*i): break if(len(a)==2 and n not in a and n>=2): 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)...
tests = int(input()) for t in range(tests): n = int(input()) initN = n i = 2 a,b = 0,0 while True: if i**2 > initN: print("NO") break if n%i == 0: n=n/i if a == 0: a=i elif b==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)...
import os import sys 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 file.mode or 'r' not in file.mode self.write = self.buffer.write if self.wri...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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.Map.Entry; import java.lang.*; import java.io.*; import java.math.BigInteger; public class CF { private static FS sc = new FS(); private static class FS { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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> const long long int mod = 1e9 + 7; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long int t = 0; cin >> t; while (t--) { long long int n = 0; cin >> n; if (n < 24) { cout << "NO\n"; continue; } else { vector<long lon...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 lli = long long int; using ulli = unsigned long long int; using db = double; using vint = vector<int>; using vlli = vector<vint>; using vvint = vector<vint>; using vvlli = vector<vlli>; using cd = complex<double>; const int inf = 1e9 + 5; const lli infl = 1e18 + 5; vo...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
t=int(input()) j=0 while j<t: n=int(input()) i=1 var1='NO' var2='NO' while i<(n**(1/3)) and var1=='NO': i+=1 if n%i==0: var1='YES' a=i if var1=='YES': product=(n/a) i=(a+1) while i<(product**(0.5)) and var2=='NO': if product%i==0: var2='YES' b=i c=product/b i+=1 if var1=='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 solve(n): for a in range(2, math.ceil(n ** (1 / 3))): if n % a == 0: for b in range(a + 1, math.ceil(math.sqrt(n // a))): c = n // a // b if c * a * b == n: print('YES') print('%d %d %d' % (a, b, 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)...
# lines = [int(line) for line in open('CodeForces_1294C.in', 'r').readlines()[1:]] lines = [int(line) for line in [*open(0)][1:]] for n in lines: sol = [] d = 2 done = False while d * d <= n: if n % d == 0: n //= d sol.append(d) if len(sol) == 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)...
from collections import Counter from collections import defaultdict import math # method to print the divisors def factors(n) : l=list() # Note that this loop runs till square root i = 1 while i <= math.sqrt(n): if (n % i == 0) : # If divisors are ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
#right preference q = int(input()) for rwre in range(q): n = int(input()) dz = [] nn = n kan = 2 while nn > 1 and kan**2 <= n: if nn%kan == 0: nn//= kan dz.append(kan) else: kan += 1 if nn > 1: dz.append(nn) dz.append(5252542554254...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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()) while t>0: d=list() n=int(input()) imp=int(n) ctr=0 for i in range (2,int(sqrt(n))): while(n%i==0): n//=i d.append(i) if(n>1): d.append(n) if(len(set(d))==2 and len(d)>=4): 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 collections import deque from math import sqrt def factors(n): d=deque() for x in range(2,int(sqrt(n)+1)): if n%x==0 : d.append(x) if n//x!=x : d.append(n//x) return d,set(d) t=int(input()) while(t): n=int(input()) f,m=factors(n) flag=a=b=c=0 for x in range(len(f)): fa,ma=...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 C1294 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); main: for (int t=0; t<T; t++) { long N = in.nextLong(); for (long a=2; a*a*a<N; a++) { if (N%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)...
from math import sqrt, ceil def primesfrom2to(n): """ Returns a list of primes < n """ sieve = [True] * (n//2) for i in range(3,int(n**0.5)+1,2): if sieve[i//2]: sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1) return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]] prime...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 i in range(int(input())) : n = int(input()) a,b = 0,0 for i in range(2, math.floor(math.sqrt(n))+1) : if n%i == 0 : a = i break if a != 0 : for j in range(a+1, math.floor(math.sqrt(n//a))+1) : if (n//i)%j == 0 : b = j ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools # import time,random,resource sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI():...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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__ = 'Devesh Bajpai' ''' https://codeforces.com/problemset/problem/1294/C Solution: We first find the factor for n using a standard sqrt time complexity stub. If we could find one, that becomes a. And then we find factor for n/a which is not equal to a. If we could find oen, that becomes b. By then, the valu...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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(0,t): n = int(input()) tmp = n lst = [] j = 2 while(j*j<=n) : if(tmp%j==0): tmp = int(tmp/j) lst.append(j) if(len(lst)>=2): if(tmp>j): lst.append(tmp) break j = j+1 if(len(l...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; int cnt = 0; vector<long long> ans; for (long long i = 2; i * i <= n; i++) { if (n % i == 0) { if (cnt == 0) { ans.push_back(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)...
for x in range(int(input())): n = int(input()) a = 1 for i in range(2, int(n ** 0.5) + 2): if n % i == 0: a = i n /= i break if a != 1: b = 1 for i in range(a + 1, int(n ** 0.5) + 2): if n % i == 0: if n // i != a an...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 defaultdict def solve(n): table = set() i = 2 while i*i <= n: if n % i == 0: table.add(i) n /= i break i += 1 i = 2 while i*i <= n: if n % i == 0 and i not in table: table.add(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 java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-- > 0) { long n=sc.nextLong(); long a=0L,b=0L,c=0L; boolean found=false; for (long i=2L...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
cases = int(input()) def prime(n): for i in range(2,int((n+1)**0.5)): if n%i == 0: return False return True for i in range(cases): num = int(input()) if prime(num): print("NO") continue if num < 24: print("NO") continue n = num d = {} 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)...
t=int(input()) for _ in range(t): n=int(input()) a=[] i=2 while len(a)<2 and i*i<n: if n%i==0: a.append(i) n//=i i+=1 if len(a)==2 and n not in a: print('YES') print(*a,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)...
from math import * for _ in range(int(input())): n = int(input()) nn = n l = [] now = 2 m = [] sq = int(sqrt(n)) while n > 1: if n % now == 0: while n % now == 0: l.append(now) n //= now else: now += 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)...
for _ in range(int(input())): n=int(input()) a=n i=2 while i**2<n: if n%i==0: a=i n//=i break i+=1 if a==n: print('NO') continue b=n i=a+1 while i**2<n: if n%i==0: b=i n//=i br...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 fac(n): return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))) t=int(input()) for i in range(t): n=int(input()) x=fac(n) x=x[1:-1] flag=1 if len(x)<3: flag=0 else: a,b=x[0],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; using namespace std; string chk[10] = {"1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011"}; void solve() { long long n; cin >> n; for (int a = 2; a * (a + 1) * (a + 2) <= n; a++) if (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)...
from functools import reduce def factors(n): return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))) t = int(input()) #for each test cases for i in range(t): n=int(input()) def x(n): x=factors(n) counter=1 if (len(x)<5): 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)...
from sys import stdin from _collections import deque mod = 10**9 + 7 import sys sys.setrecursionlimit(10**5) from queue import PriorityQueue from bisect import bisect_right from bisect import bisect_left from _collections import defaultdict from math import sqrt,factorial,gcd,log2,inf,ceil import heapq input = lambda :...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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) f=0 for i in ra...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 fin(n): for a in range(2,int(n**(1/3))+1): if n%a==0: x=n/a for b in range(2,int(x**(1/2))+1): if x%b==0: y=int(x/b) if a!=b and b!=y and y!=a: return a,b,y return 0,0,0 for _ in range(int(input())): n=int(input()) p,q,r=0,0,0 p,q,r=fin(n) if p!=0: print("YES") print(p,q,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)...
n=int(input()) for i in range (n): a=int(input()) k=a p=[] j=2 while (j*j<k): if (k%j==0 and j not in p): p.append(j) k=k//j if (len(p)==2): g=a//(p[0]*p[1]) if (g!=p[0] and g!=p[1]): break j+=1 if len(p)<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)...
from math import gcd,sqrt t = int(input()) for _ in range(t): n = int(input()) flag = 0 for i in range(2,int(sqrt(n))+1): if flag: break if n%i==0: divided = n//i for j in range(2,int(sqrt(n))+1): if divided%j==0 and divided//j > 1 and 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() { int T, t; cin >> T; for (t = 0; t < T; t++) { int n, i; cin >> n; int numPrime = 0; int num = n; int f = 1; vector<int> v; map<int, int> mp; for (i = 2; i <= sqrt(n); i++) { f = 1; if (num % i == 0) { 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)...
from sys import stdin t = int(stdin.readline()) for _ in range(t): n = int(stdin.readline()) if n < 24: print("NO") continue a = [] for i in range(2, int(n**0.5)+1): if n%i == 0: n//=i a.append(i) break if len(a) == 1: for i in ran...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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): f = 0 n = int(input()) if n % 2 == 0: a = 2 f = 1 else: for j in range(3 ,int((n**(1/3)) + 2), 2): if (n % j == 0): a = j f = 1 break if (f == 0): print("NO") els...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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()) def prime(n): primes = {2:0} while n % 2 == 0: primes[2] += 1 n = n // 2 for i in range(3, int(math.sqrt(n)+1), 2): while n % i == 0: if i in primes: primes[...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 ip = lambda : sys.stdin.readline().rstrip() for _ in range(int(ip())): n=int(ip()) ans=[] for i in range(2,int(n**0.5)+1): if n%i==0: v=n//i for j in range(2,int(v**0.5)+1): if v%j==0: st=set([i,j,v//j]) if 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)...
t = int(input()) for i in range(t): n = int(input()) f = 2 li = [] c = 0 while c < 2 and n >= f * f: if n % f == 0: n = n // f c += 1 li.append(f) if c == 2: if n not in li and n >= 2: li.append(n) f += 1 if len(li) == 3: print("YES") print(li[0], li[1], li[2]) 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 collections,math for _ in range(int(input())): n=int(input()) factors=[] flag=False d=collections.defaultdict(int) for i in range(2,int(math.sqrt(n))+1): if n%i==0: d[i]=1 factors.append(i) if (n//i) != i: d[n//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)...
import java.util.*; import java.io.*; public class Main { static class pair implements Comparable<pair>{ int a; int b; public pair(int a, int b){ this.a=a; this.b=b; } public int compareTo(pair p){ return (a-p.a==0)?b-p.b:a-p.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)...
import java.util.*; import java.io.*; public class Main { public static void solve(InputReader in) { int n = in.readInt(); HashSet<Integer> set = new HashSet<>(); for(int i = 2; i*i <= n; i++) { if(n % i == 0) { set.add(i); set.add(n/i); } } for(Integer i : set) { int a = i; for(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 math import sqrt def main(): def solve(): n = int(input()) a = 0 if n%2 == 0: a = 2 else: for i in range(3, int(n ** (1./3))+1, 2): if n%i == 0: a = i break if a == 0: 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 java.util.*; public class ProductOfThreeNumbers { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); int k=n; int ans=0; int count=0; outer: for(int i=2;i<Math.sqrt(n)+1;i++) { n=k; if(n%i==0 && i!=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 for _ in range(int(input())): n=int(input()) a=[] s=round(math.sqrt(n)) for i in range(2,s+1): if len(a)==2: if n not in a: a.append(n) break else: if n%i==0: a.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)...
num = int(input()) answer = [] for i in range(num): target = int(input()) lis = [] k = 2 while len(lis)<2 and k**2<target: if target % k == 0: target = target //k lis.append(k) k += 1 if len(lis) == 2 and target not in lis: answer.append([lis[0],lis[1...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import java.util.*; import java.io.*; import java.math.*; public class Main { final static int mod = 1000000007; static FastReader sc; static PrintWriter out; static boolean test_case_input = true; public static void solution() throws IOException { int n = sc.nextInt(); int 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)...
import sys import math import heapq import collections def inputnum(): return(int(input())) def inputnums(): return(map(int,input().split())) def inputlist(): return(list(map(int,input().split()))) def inputstring(): return([x for x in input()]) def inputstringnum(): return([ord(x)-ord('a') for x in...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math t = int(input()) for ii in range(0,t): n = int(input()) a = 0 b = 0 c = 0 if n<24: print("NO") continue ifFind = 0 for i in range(2,int(math.sqrt(n))+1): if ifFind == 1: break if n%i!=0: continue n2 = n // i for j in range(i+1,int(math.sqrt(n2))+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)...
t=int(input()) from math import sqrt primes=[True for i in range(10**5)] for i in range(2,len(primes)): jumper=i ind=2 while i*ind<len(primes): primes[i*ind]=False ind+=1 primes=set([i for i in range(len(primes)) if primes[i]]) def divider(x): if x%2==0: return x//2,2 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)...
def R(): return map(int, input().split()) def I(): return int(input()) def S(): return str(input()) def L(): return list(R()) from collections import Counter import math import sys for _ in range(I()): n=I() div=[] n2=n for i in range(2,int(math.sqrt(n))+1): if n%i ==0: div.app...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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()) i=2 arr=[] while n>0 and i<=(int(n**0.5)): if n%i==0: n/=i arr.append(i) i+=1 if len(arr)==2: break if len(arr)==2: if n not in arr: print('YES') print(arr[0],arr[...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 as S def div(x): d=[] if x==1: return [1] if x==2: return [1,2] cnt=[1,n] for i in range(2,int(S(x))+1): if x %i==0: cnt.append(i) return cnt def check(arr): if 1 in arr or 0 in arr: return 0 return len(set(arr))==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)...
def main(): t = int(input()) for z in range (t): n = int(input()) arr = [] i=2; while i*i <= n: while n%i==0: arr.append(i) n //= i i += 1 if n>1:arr.append(n) a,b,c = 1,1,1 for x in arr: ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 import os def get_array(): return list(map(int, input().split(' '))) def get_divisions(a): i = 2 while i <= math.sqrt(a): if a % i == 0: yield i i += 1 yield -1 if __name__ == '__main__': t = int(input()) for i in range(t): n = int(input()) ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you **************************************** *...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 solve(R:list): n = int(input()) m = n for i in range(2,int(sqrt(m))): if i >= n : return if n % i == 0: R.append(i) n //= i if len(R) == 2: break if len(R) == 2: if n > R[-1]: R.appe...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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.math.*; import java.io.*; public class input2 { public static int factoiral(int a) { if (a == 0) return 1; else return (a * factoiral(a - 1)); } public static void sortbyColumn(int arr[][], int col) { Arrays.sort(arr, new Comparator<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)...
t = int(input()) while t: t-=1 n = int(input()) i = 2 val = [] while(i*i<=n): if n%i==0: n = n//i val.append(i) break i+=1 i = 2 while(i*i<=n): if n%i==0 and i!=val[0]: n = n//i val.append(i) brea...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Main { static String s; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br= new BufferedRea...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can 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 isPrime(int n) { if (n <= 1) return 0; for (int i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; if (isPrime(n)) cout << "NO\n"; else { int 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 java.io.*; import java.util.*; public class CF1294C extends PrintWriter { CF1294C() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1294C o = new CF1294C(); o.main(); o.flush(); } void main() { int t = sc.nextInt(); while (t-- > 0) { int n = 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 prime_factorize(n): a = [] if n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n and len(a)<2: if n % f == 0: a.append(f) n //= f f += 1 else: f += 1 if n != 1 and n not in a: a.append(n) return a Y...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
import math # A function to print all prime factors of # a given number n def primeFactors(n,l): # Print the number of two's that divide n while n % 2 == 0: l.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): ...
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
//Product of three numbers import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProductOfThreeNumbers { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReade...