Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors m = int(input()) for i in range(m): n = int(input()) if len(prime_factors(n)) <...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.Scanner; public class Main { 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(); int cnt = 0; int[] res = new int[3]; for (int j = 2; j * j <= n; j++) { if(cnt == 2) break; if...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math t=int(input()) while(t): t-=1 n=int(input()) ans=-1 if n<24: print("NO") continue else: root=int(math.sqrt(n)) factors=set() for i in range(2,root+1): if n%i==0: factors.add(i) factors.add(n//i) # ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def min_dev(n,temp): while temp<n**0.5+1: if n%temp==0: return temp temp+=1 return 0 for _ in range(int(input())): n=int(input()) a=min_dev(n,2) if a==0: print('NO') continue b=min_dev(int(n/a),a+1) if b==0: print('NO') continue ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class _13ProductOfThreeNumbers { public static void main(String[] args) { FastInput input = new FastInput(); PrintWriter output = new Pri...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math def prime(n): flag=0 for i in range(2,int(math.sqrt(n))+1): if(n%i==0): flag=1 break if(flag!=1): return 1 else: return 0 t=int(input()) while(t!=0): n=int(input()) n1=n flag=0 if((prime(n)==0) and n>=24): for i in range...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
n = int(input()) for _ in range(n): ans = [] x = int(input()) f = 2 while len(ans) < 2 and f ** 2 < x: if x % f == 0: ans.append(f) x //= f f += 1 if len(ans) == 2 and x > ans[1]: print('YES') print(ans[0], ans[1], x) else: print('...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; void Doaa() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { Doaa(); int n, t, num1 = 0, count = 0; cin >> t; while (t--) { count = 0; cin >> n; int x = n; bool f = true; for (int i = 2; i <= sqrt(n); i++) { if (n % ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from __future__ import division, print_function def main(): for _ in range(int(input())): n = int(input()) x = int(n**0.5) i = 2 factors = [] while i <= x and n > 1: if n%i==0: factors.append(i) n=n//i else : ...
PYTHON
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def factorize(n): l=[] for i in range(2,int(n**0.5)+1): if len(l)==2 and n>=i: l.append(n) break if n<=1: break if n%i==0: n=n//i l.append(i) return l for _ in range(int(input())): n=int(input()) l=factorize(n) i...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); static int MOD = 1000000007; public static void main(String[] args) throws IOException { ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
# Python program to print prime factors import math # A function to print all prime factors of # a given number n def primeFactors(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 ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math t=int(input()) for _ in range(t): n=int(input()) if(n<24): print("NO") else: l=[] temp=n for i in range(2,math.ceil(math.sqrt(n))+1): if(temp%i==0): l.append(i) temp=temp//i if(len(l)==2): bre...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def req(n): k = int(n ** (1 / 2)) for a in range(2, k): if n % a == 0: for b in range(2, k): if b != a: if n % (a * b) == 0: c = n // (a * b) if b != c and a != c: return [a, b, c]...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math def factor(n,a): l=[] r=n k=int(math.sqrt(n))+1 d=1 while n%(2**d)==0: if 2**d!=a and r//(2**d)!=a and r//(2**d)!=2**d and 2**d!=r: l.append(2**d) l.append(r//2**d) n//=2**d d+=1 break ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math from collections import defaultdict def divisors(n, ans): i = 2 while i <= math.sqrt(n): if (n % i == 0): if (n / i == i): ans.append(i) else: ans.append(i) ans.append(n // i) i = i + 1 for _ in range(int(input...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; using pii = pair<int, int>; const int MOD = 1e9 + 7; const int MAX = 1e5 + 5; const ll INF = 1e18 + 1; void err(...) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a,...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math def splitPrime(n): arr = {} for i in range(2, math.ceil((math.sqrt(n))) + 1): while n != 0 and n % i == 0: f = arr.get(i, 0) arr[i] = int(f + 1) n = n // i if n > 1: arr[n] = 1 return arr t = int(input()) for i in range(t): n = int(inp...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math t=int(input()) while(t): n=int(input()) a=[] for i in range(2,int(math.sqrt(n))+1): if n%i==0: a.append(i) n=n//i if len(a)==2: break if len(a)==2 and n!=1: if n not in a: print("YES") print(a[0],a[1],n) ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; long long q, n; long long ans1, ans2, ans3; long long cnt, a[1000005]; signed main() { cin >> q; while (q--) { cnt = 0; cin >> n; for (long long i = 2; i * i <= n; i++) if (n % i == 0) { a[++cnt] = i; a[++cnt] = n / i; } if (c...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
# cook your dish here import math def primeFactors(n): arr=[] while n % 2 == 0: arr.append(2) n = n / 2 for i in range(3,int(math.sqrt(n))+1,2): while n % i== 0: arr.append(i) n = n / i if n > 2: arr.append(n) return arr t=in...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.io.*; import java.math.*; import java.util.*; public class A { public static void main(String[] agrs) throws IOException { // PrintWriter pw = new PrintWriter(System.out); FastScanner sc = new FastScanner(); int yo = sc.nextInt(); while(yo-->0) { int n = sc.nextInt(); if(n < 8) ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def factor(x): p = [] d = 2 while d * d <= x: if x % d == 0: p.append(d) x //= d else: d += 1 if x > 1: p.append(x) return p t = int(input()) for i in range(t): n = int(input()) p = factor(n) a, b, c = 1, 1, 1 ans = 'NO' ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import sys, itertools, math T = int(sys.stdin.readline()) def solve(n): for a in range(2, int(math.sqrt(n))+1): if n % a != 0: continue for b in range(a+1, int(math.sqrt(n))+1): r = a * b c = n // r if n % r == 0 and c != a and c != b: print("YES") print(a, b, c) ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#----------------- # cook your dish here #############----------------- ######----- import math ########### ##### try: ####### def func1(t2,io):############# ###### ########## if len(io) >= 3 and len(t2) >= 3:###### ########## y = t2[1]###### ####### ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#C for _ in range(int(input())): n = int(input()) cnt=0 ans = [] for i in range(2,int(n**0.5)+1): if n % i == 0: cnt+=1 ans.append(i) if cnt == 2 and n % (ans[0]*ans[1]) == 0 and n//(ans[0]*ans[1]) != ans[0] and n//(ans[0]*ans[1]) != ans[1]: break ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t=int(input()) for q in range(t): n=int(input()) c=[] i=2 while len(c)<2 and i*i<n: if n%i==0: c.append(i) n=n/i i=i+1 if len(c)==2: print("YES") print(*c,int(n)) else: print("NO")
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for t in range(int(input())): n = int(input()) try: a = next(i for i in range(2, int(n**0.5)+1) if n%i == 0) n//=a b = next(i for i in range(a+1, int(n**0.5)+1) if n % i == 0) if n//b <= b: raise else: print("YES") print(a, b, n//b) ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#create a string in which no two same char comes together. # assumption only small albhabetical letters used #input format: just enter the string without any space import sys import math input = sys.stdin.readline ############ ---- Input Functions ---- #######Start##### def inp(): return(int(input())) def inlt(): ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int ans1, ans2, n, T; inline int read() { int x = 0; int flag = 0; char ch; ch = getchar(); while (!isdigit(ch)) { if (ch == '-') flag = 1; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar(); } if (fla...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.*; // scanner.nextInt(); public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int test_case = scanner.nextInt(); for(int z = 0; z < test_case; ++z) { int n = scanner.nextInt(); ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { set<int> s; int count = 0; int a; cin >> a; for (int i = 2; i * i <= a; i++) { if (a % i == 0) { int u = a / i; s.insert(i); for (int j = i + 1; j * j <= u; j++) { ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import sys input = sys.stdin.readline def solve(): n = int(input()) ans, ind = [], 2 while len(ans) < 2 and ind < n ** (1 / 2): if not n % ind: n = n // ind ans.append(ind) ind += 1 return ans + [n] for _ in range(int(input())): sol = solve() if len(so...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#!/usr/bin/env python3 R = lambda: list(map(int, input().split())) def solve(): n = R()[0] a, cnt, i = [0, 0], 0, 2 while i * i < n and cnt < 2: if n % i == 0: a[cnt] = i cnt += 1 n //= i i += 1 if cnt < 2: print("NO") else: prin...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 1e8 + 1; const long double PI = 3.141592653; bool isp(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) return 0; } return 1; } int main() { int tc; cin >> tc; while (tc--) { int n; cin >> n; if (isp(n)) { cout << ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def process(n,i,sol): for j in range(i+1,int(n**(0.5))+1): if n%j==0: sol.append(j) if len(sol)==1: process(n//j,j,sol) break if len(sol)==2: if j!=n//j: sol.append(n//j) break return ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { long long n; cin >> n; if (n < 24) { cout << "NO" << endl; continue; } long long p = 0; for (long long i = 2; i <= sqrt(n); i+...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def main(): T = int(input()) for t in range(T): m = int(input()) n = m dic = {} i = 2 while i * i <= n: while n % i == 0: dic[i] = dic.get(i, 0) + 1 n //= i i += 1 if m % n == 0 and n != 1: dic[n]...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def nonprime(number,start=2): from math import sqrt for i in range(start,int(sqrt(number))+1): if number%i==0: return [True,i] return [False] testcases=int(input()) for k in range(testcases): numbertobetested=int(input()) initial=nonprime(numbertobetested) if initial[0]: ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.Scanner; public class productod3{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for(int k = 0; k < t; k++){ int n = scan.nextInt(); if(!func(n)){ System.out.println("NO"); } } } public static Boolean func(int n)...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
n = int(input()) for k in range(n): z = int(input()) l = [] for i in range(2 , z): if z % i == 0: l.append(i) z = z // i break if (i * i) > z: break for j in range(2 , z): if z % j == 0 and j not in l: l.append(j) ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.*; import java.io.*; import java.math.*; import java.security.*; public class Main { public static void main(String[] args)throws Exception { Reader reader = new Reader(); reader.readLine(); int t = reader.readInt(0); StringBuilder res = new StringBuilder(); while (t-- > 0) { r...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def solve(): n = int(input()) primes = {} i = 2 while i * i <= n: while n % i == 0: primes[i] = primes.get(i, 0) + 1 n //= i i += 1 if n > 1: primes[n] = primes.get(n, 1) k = list(primes.keys()) v = list(primes.values()) if len(primes) >= 3...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import sqrt as s def factorization(n): a=[] while n%2==0: a.append(2) n = n//2 for i in range(3,int(s(n))+1,2): while n%i==0: a.append(i) n = n//i if n>2: a.append(n) return a for i in range(int(input())): ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t = int(input()) for i in range(t): l = [] n = int(input()) for i in range(2,n): if n%i == 0: l.append(i) n /= i if len(l) == 2 or i*i>n: break if len(l) == 2 and n!=l[0] and n!= l[1] and n>1: print("YES") print(l[0],l[1],int(n)) else: print("NO")
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from sys import stdin, stdout from collections import defaultdict import math rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() def main(): cases = rll() for line in stdin: n = int(line) ans = [] for f1 in range(2, math.ceil(math.sqrt(n))): if n % f1 == 0: ans.append(f1) break i...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; long long myCeil(long long num, long long divider) { long long result = num / divider; if ((result * divider) == num) return result; return result + 1; } long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } bool isPrime(long long n) ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t = int(input()) for i in range(t): n = int(input()) p = [] j = 2 while j * j <= n: while (n % j == 0): p.append(j) n //= j j += 1 if n > 1: p.append(n) if len(p) < 3: print("NO") elif len(p) == 3: if p[0] != p[1] and p[1] != p[2] and p[0] != p[2]: print("YES") print(p[0], p[1], p[2]) els...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for _ in range(int(input())): n = int(input()) c = [] i=2 while len(c)<2 and i**2<n: if n % i == 0: c.append(i) n=n/i i=i+1 if len(c)==2 and n not in c: print("YES") print(*c,int(n)) else: print("NO")
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; long long myCeil(long long num, long long divider) { long long result = num / divider; if ((result * divider) == num) return result; return result + 1; } long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } bool isPrime(long long n) ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int tab[50000]; int main() { int t; int long long n, a, b, c, maxi; scanf("%lld", &t); while (t--) { int s = 0; int long long i = 2, j = 2, sq; scanf("%lld", &n); sq = sqrt(n); while (n != 0 && i <= sq) { if (n % i == 0) { tab[s] = ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import sqrt def fatores(n): fat = {} for p in range(2, int(sqrt(n)+1)): while n % p == 0: n/=p if not fat.get(p): fat[p] = 0 fat[p]+=1 p+=1 if n > 1: fat[int(n)] = 1 return fat for _ in range(int(input())): ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t = int(input()) for _ in range(t): n = int(input()) d = [] a = n i = 2 while i * i <= a: while a % i == 0: d.append(i) a //= i i += 1 if a != 1: d.append(a) a = d[0] b = 1 c = 1 for i in range(1, len(d)): if a == b or b == ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import sys import math from collections import defaultdict from collections import deque from itertools import combinations from itertools import permutations input = lambda : sys.stdin.readline().rstrip() read = lambda : list(map(int, input().split())) go = lambda : 1/0 def write(*args, sep="\n"): for i in args: ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t=int(input()) for tt in range(t): n=int(input()) d={} for i in range(2,int(n**0.5)+1): if n%i==0 and i not in d: d[i]=1 n=n//i break for i in range(2,int(n**0.5)+1): if n%i==0 and i not in d: d[i]=1 n=n//i break if len(d)<2 or (n in d) or n==1: print("NO") else: print("YES") d[n]=1...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; // static long oo = (long)1e15; static int mod = 1_000_000_007; // static int mod = 998...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import ceil def find(n,p,ans): for i in range(2,ceil(n**(1/p))+1,1): if n%i==0: if p==3: ans+=find(n//i,2,[i]) if len(ans)==3: return ans ans=[] elif p==2 and n//i>1: new=ans+[(n//i),i] ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
# -*- coding: utf-8 -*- from math import sqrt def main(): for _ in range(int(input())): n = int(input()) d = n ret = [] for i in range(2, int(sqrt(n))): if d % i == 0: d /= i ret.append(i) if len(ret) == 2: bre...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t = int(input()) def find_one_factor(num, a): for i in range(2, int(num ** 0.5) + 1): if num % i == 0: if a == i: continue return i, num // i return -1, -1 while t: t -= 1 n = int(input()) flag = True factors = [] a, num = find_one_factor...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import sqrt T = int(input()) for case in range(T): n = int(input()) ans = False move = True for i in range(2,int(sqrt(n)) + 1): if move is False:break if n%i == 0: a = i b = int(n/a) for j in range(a + 1 , int(sqrt(n)) + 1): if (b%j == 0): b = b//j c = j if (c==b or c==a or...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
//Contribted By - Rahul Roy import java.util.*; import java.lang.*; import java.io.*; public class Main { public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out)); public static void main(String sp[])throws IOException{ FastReader sc = new FastReader(); int t = sc.nextInt(); whil...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for _ in range(int(input())): n = int(input()) ans = [] i = 2 x = n while i * i <= x: if n % i == 0: if len(ans) < 2: ans.append(i) n //= i i += 1 if n not in ans and len(ans) < 3: ans.append(n) if len(ans) > 2: prin...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import * for ct in range(int(input())): n = int(input()) flag = False for i in range(2, int(sqrt(n))): if flag: break if n % i == 0: par = n//i for j in range(2, int(sqrt(par))+1): if par % j == 0: k = par //...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import sys from os import path if(path.exists('input.txt')): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') get_int = lambda: int(input()) get_ints = lambda: map(int, input().split()) get_ints_list = lambda: list(get_ints()) from math import sqrt def factorize(n): i = 2 facto...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for _ in [0]*int(input()): n = int(input()) i = 2 tt = False delim = [] while i*i <= n: if not n % i: delim.append(i) i += 1 for i in range(len(delim)): if tt == True: break for j in range(i+1, len(delim)): f = n // (delim[i]*de...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { long long int a, b, c, n; cin >> n; int e = 0; long long int d; for (int j = 2; j <= (int)sqrt(n); j++) { if (n % j == 0) { e = 1; d = n / j; a = j; b...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> void inpos(T &x) { x = 0; register T c = getchar(); while (((c < 48) || (c > 57)) && (c != '-')) c = getchar(); bool neg = 0; if (c == '-') neg = 1; for (; c < 48 || c > 57; c = getchar()) ; for (; c > 47 && c < 58; c = getchar()) x =...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t = int(input()) for _ in range(t): n = num = int(input()) arr = [] div = 2 while n != 1: if div > int(n**0.5): arr.append(n) n //= div break if n % div == 0: n //= div arr.append(div) continue div += 1 ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import sqrt t = int(input()) for _ in range(t): n = int(input()) i = 2 fact = [] while n%i == 0: n = n//i fact.append(i) for i in range(3, int(sqrt(n))+1, 2): while n%i == 0: n = n//i fact.append(i) if n != 1: fact.append(n) if len(fact) < 3: print('NO') continue ans = 1 i = 0 fac...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for _ in range(int(input())): n = int(input()) prime = [] for i in range(2, int(n ** 0.5) + 1): if n % i == 0: prime.append(i) n //= i if n != 1: prime.append(n) if len(prime) < 3: print("NO") else: if len(set(prime)) < 3: print...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import sqrt t= int(input()) while t: n= int(input()) r=n a=[] for i in range(2,int(sqrt(n))): if n%i==0: a.append(i) n=int(n/i) if len(a)==2: break if len(a)==2 and a[0]!=a[1] and a[1]!=n and a[0]!=n and n>=2: print("YES",a[0],a[1],n) e...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> primefactors(int n) { vector<int> ans; while (n % 2 == 0) { ans.push_back(2); n = n / 2; } for (int i = 3; i * i <= n; i += 2) { while (n % i == 0) { ans.push_back(i); n = n / i; } } if (n > 2) { ans.push_back(n); } ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t = int(input()) for _ in range(t): n = int(input()) #n,k = map(int,input().split()) for a in range(2,int(n**0.5)+1): if n%a == 0:break else: print ("NO") continue ne = n//a for b in range(2,int(ne**0.5)+1): if b == a: continue if ne%b == 0:b...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for i in range(int(input())): n=int(input()) a=[] d=2 while (d*d<n) and len(a)<2: if n%d==0: a.append(d) n//=d d+=1 if len(a)<2: print("NO") else: print("YES") print(n,*a)
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import sys def fastio(): from io import StringIO from atexit import register global input sys.stdin = StringIO(sys.stdin.read()) input = lambda : sys.stdin.readline().rstrip('\r\n') sys.stdout = StringIO() register(lambda : sys.__stdout__.write(sys.stdout.getvalue())) fastio() for _ in rang...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import * for _ in range(int(input())): n = int(input()) e = [] a = False for i in range(2, int(sqrt(n)) + 1): m = n / i if m.is_integer() == True: for j in range(2, int(sqrt(m)) + 1): if m % j == 0: if (n / (i * j)).is_integer() =...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
for _ in range(int(input())): n=int(input()) k=[] for i in range(2,10000): if n%i==0: k.append(i) n=n//i break for j in range(2,10000): if n%j==0: if j not in k: k.append(j) n=n//j break ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { int n = s.nextInt(); int i = 2; int a = -1; int b = -...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math a = int(input()) for x in range(a): a = int(input()) prime = 2 count = list() while prime <= math.ceil(math.sqrt(a)): if a % prime == 0: a /= prime count.append(prime) if len(count) == 2: if not a in count: prin...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import sys import math input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) t = ini() ans = [] andsindex = [0] * t for _ in range(t): n = ini() i = 2 tmp = [] while n >= i * i:...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.*; import java.io.*; public class Main { public static void main(String []args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); solve(in, out); in.close(); o...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; int main() { int a, b, c, d, t; scanf("%d", &t); while (t--) { int flag = 0; scanf("%d", &n); a = 0; b = 0; for (int i = 2; i < sqrt(n); i++) { if (n % i == 0) { if (a == 0) { a = i; n /= i; } els...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int a = 2; while (a * a <= n) { if (n % a == 0) { n /= a; break; } ++a; } int b = a + 1, c = -1; while (b * b < n) { if (n % b == 0) { if (n / b != a) { c = n / b; cout << "YES" ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math t = int(input()) for i in range(t): n = int(input()) a=0 b=0 c=0 j=2 while(j<=math.sqrt(n)): if(n%j==0): if(a==0): a=j n=int(n/j) j+=1 else: b=j c=int(n/j) break else: j+=1 if(a!=0 and b!=0 and c!=0) and(a!=b and b!=c and a!=c) and (a>=2 and b>=2 and c>=2): pri...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.* ; import java.math.*; import java.io.*; public class javaTemplate { // public static final int M = 1000000007 ; public static final int M = 1000003 ; static FastReader sc = new FastReader(); // static Scanner sc = new Scanner(System.in) ; public static void main(String[] args) { ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
'''input 5 64 32 97 2 12345 ''' from collections import defaultdict as dd from collections import Counter as ccd from itertools import permutations as pp from itertools import combinations as cc from random import randint as rd from bisect import bisect_left as bl from bisect import bisect_right as br import heapq as ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int k = n; vector<long long int> b; for (int i = 2; i < sqrt(k) + 1; i++) { if (n % i == 0) { b.push_back(i); n /= i; } if ...
CPP
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
def getFactors(n): fact = [] i =2 while i*i <=n: if n%i==0: fact.append(i) if(i!=n//i): fact.append(n//i) i+=1 return fact t = int(input()) while t>0: n = int(input()) fact = getFactors(n) fact.sort() found = False for i in ran...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math def primeFactors(n,d): # Print the number of two's that divide n while n % 2 == 0: try: if d[2]>=0: d[2]+=1 except: d[2]=1 n = n / 2 # n must be odd at this point # so a skip of 2 ( i = i + 2) can be used ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
//package main; import java.io.*; import java.util.*; public final class Main { BufferedReader br; StringTokenizer stk; public static void main(String[] args) throws Exception { new Main().run(); } { stk = null; br = new BufferedReader(new InputStreamReader(System.in)...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import * t = int(input()) for z in range(t): n = int(input()) na = True sq = ceil(sqrt(n)) + 1 for a in range(2, sq): if not na: break if n % a == 0: q = n // a sq2 = ceil(sqrt(q)) + 1 for b in range(a + 1, sq2): i...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.io.*; import java.util.*; public class Bacteria { public static void main(String args[]) throws IOException{ Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t--!=0){ int n = sc.nextInt(); ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math def primeFactors(n): vals = [] # Print the number of two's that divide n two = False while n % 2 == 0: vals.append(int(n)) if not two: vals.append(2) two = True n = n / 2 # n must be odd at this point # so a skip of 2 ( i = i + 2) can ...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
/* Author: Anthony Ngene Created: 09/09/2020 - 06:52 */ import java.io.*; import java.util.*; public class C { // CodeForces.Div3.CF1385_656.P1.A mind is like a parachute. It doesn't work if it isn't open. - Frank Zappa void solver() throws IOException { int cases = in.intNext(); for (int ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args)throws IOException{ Scanner sc = new Scanner(System.in); long a,b,c,d,e,f,g,h,i,j,k; a = sc.nextLong(); for(b = 0;b < a;b++){ c = sc.nextLong(); d = (long)Math.sqrt(c); if(c % 2 == 0){ ...
JAVA
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
t=int(input()) for _ in range(t): n=int(input()) tf=False for i in range(2,int(n**(1/2))+1): if n%i==0: a=i b=n//i tf=True break if tf: tf=False for i in range(2,int(b**(1/2))+1): if b%i==0: if i!=a and b...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
from math import ceil, sqrt t = int(input()) for _ in range(t): n = int(input()) if n < 24: print('NO') else: try: for i in range(4, ceil(sqrt(n)) + 1): if n % i == 0: a = n // i b = i for j in range(2,...
PYTHON3
1294_C. Product of Three Numbers
You are given one integer number n. Find three distinct integers a, b, c such that 2 ≀ a, b, c and a β‹… b β‹… c = n or say that it is impossible to do it. If there are several answers, you can print any. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 100)...
2
9
import math t = int(input()) for i in range(t): n = int(input()) L, a, r = [], n, [] m = math.ceil(math.sqrt(n)) f = False for j in range(2, m+1): if a % j == 0: c = 0 while a % j == 0: a //= j c += 1 L.append((j, c)) ...
PYTHON3