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)... | def smallestDivisor(n, a):
if not n & 1 and a != 2:
return 2
i = 3
while i*i <= n:
if n % i == 0 and a != i:
return i
i += 1
return n
t = int(input())
for _ in range(t):
n = int(input())
a = smallestDivisor(n, 1)
b = smallestDivisor(n//a, a)
c = 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;
const long long N = 1e5 + 10;
vector<long long> ans;
pair<long long, long long> a[N];
long long n, T;
void f(long long n) {
ans.clear();
long long x = n;
for (long long i = 2; i * i <= x; i++) {
while (x % i == 0) {
ans.push_back(i);
x = x / 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.*;
public class Solution{
static FastReader in = new FastReader();
//static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws Exception{
int t = in.nextInt();
while(t-- > 0){
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
for _ in range(t):
n = int(input())
l1 = []
i = 2
while len(l1)<2 and i*i <n:
if n%i == 0:
l1.append(i)
n = n//i
i+=1
if len(l1)==2:
print('YES')
for i in l1:
print (i,end = ' ')
print(n)
else:
p... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def find_div(x, j):
for i in range(2, int(x**.5)+1):
if x % i == 0 and i != j and x//i !=j and i != x//i:
return True, i, x//i
return False, -1, -1
t = int(input())
for _ in range(t):
n = int(input())
for i in range(2, int(n**.5)+1):
if n % i == 0:
ok, a, b = fin... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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())
f=set()
for i in range(2,int(pow(n,0.5))+1):
if(n%i==0):
f.add(i)
f.add(n//i)
flag=0
for i in f:
x=n//i
for j in f:
if(x%j==0):
z=[i,x//j,j]
p=i*j*(x//j)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
import java.util.Scanner;
public class ProductofThreeNumbers {
public static int findFirstDivisor(int n, int t) {
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0 && n / i != t && i != t && n != i && n / i != i) {
return i;
}
}
return 0;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
from collections import Counter
def primeFactors(n):
# Print the number of two's that divide n
l = []
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)... | for _ in range(int(input())):
n = int(input())
ok = False
for i in range(2, int(n**0.5)+1):
if n % i ==0:
p = n//i
if p == i:
continue
for j in range(i+1, int(p**0.5)+1):
if p%j == 0:
if j*j!=p and p//j != i:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
for _ in range(int(input())):
n=int(input())
l=[]
for i in range(2,int(math.sqrt(n))+1):
if(n%i==0):
t=n
l.append(i)
t=t//i
for j in range(2,int(math.sqrt(t)+1)):
if(t%j==0):
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | /*package whatever //do not write package name here */
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
long num = sc.nextLong();
long n = num;
int count = 0;
long[] arr = new long... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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
cin = stdin.readline
cout = stdout.write
mp = lambda:list(map(int, cin().split()))
t, = mp()
for _ in range(t):
n, = mp()
if n < 24:
cout('NO\n')
continue
y = int(n**.5)
l = []
for i in range(2, y+1):
if not n%i:
l += [i, n//i]
if len(l)<4:
cout('NO\n')
continue
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)... | import java.util.*;
import java.io.*;
public class Solution{
public static void main(String[] args) throws Exception{
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(buffer.readLine());
while(t-- > 0){
long num ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for _ in range(int(input())):
n=int(input())
a=[]
f=n
i=2
while len(a)<2 and i*i<=n:
if n%i==0:
a.append(i)
n=n//i
i+=1
if len(a)<2 or n in a:
print('NO')
else:
print('YES')
print(*a,n)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSe... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static ArrayList<Long> primeFactors(long n)
{
ArrayList<Long> arr=new ArrayList<>();
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 two_dist(n, k):
ans = []
for i in range(2, int(sqrt(n))+5):
if n % i == 0:
if i != n//i and i != k and n//i != k and n//i >= 2:
return [i, n//i]
return False
for _ in range(int(input())):
n = int(input())
ans = []
for p in range(2, i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
def foo(n):
x=pow(n,.5)
x=int(x)+1
l=[]
for i in range(2,x):
if n%i==0:
z=n//i
l.append(i)
if z!=i:
l.append(z)
l.sort()
if len(l)>=3:
for i in range(0,len(l)-1):
k=l[i]*l[i+1]
z=n//k
if (z in l) and z!=l[i] and z!=l[i+1]:
print("YES")
k=[l[i],l[i+1],z]
print(*k)
return ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class productOfThree {
static BufferedReader b = new BufferedReader(new InputStreamReader(Sys... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;
public class C {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int test = 0; test < t; test++) {
n = in.next... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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.math.*;
import java.util.*;
import java.lang.*;
public class Main implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilte... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 S{
static ArrayList<Integer> al=new ArrayList<>();
public static ArrayList<Integer> primeFactors(int n)
{
// Print the number of 2s that divide n
while (n%2==0)
{
al.add(2);
//System.out.print(2 + " ");
n /= 2;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.Scanner;
/**
* Created by abhay.kumar on 26/01/20.
* 1294 C
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] query = new int[n];
for (int i = 0; i < n; i++) {
query[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.HashSet;
import java.util.Iterator;
import java.util.Scanner;
public class Solution {
private static HashSet<Integer> set = new HashSet<>();
private static void process(int num, int init){
for(int i = init; i * i <= num; i++){
if(num % i == 0){
if(set.siz... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 int INF = 0x3f3f3f3f;
using namespace std;
const int MAXN = 1000;
int prime[MAXN + 1];
void getPrime() {
memset(prime, 0, sizeof(prime));
for (int i = 2; i <= MAXN; i++) {
if (!prime[i]) prime[++prime[0]] = i;
for (int j = 1; j <= prime[0] && prime[j] <= MAXN / i; j++) {
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
public class MyClass {
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 b=0;
int arr[]=new int[3];
for(int j=2;j*j<n;j++)
{
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &u) {
u = 0;
char c = getchar();
long long flag = 0;
while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
while (c >= '0' && c <= '9')
u = (u << 3) + (u << 1) + (c ^ 48), c = getchar();
if (flag) u = -u;
}
template <cl... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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())
li=list()
j=2
while len(li)<2 and j*j<n :
if n%j==0 :
li.append(j)
n=n//j
j+=1
if len(li)==2 and n not in li :
print("YES")
for i in li :
print(i,end=" ")
print(n)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
# import numpy as np
t = int(input())
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)... | for _ in range(int(input())):
n=int(input())
i=2
ans=[]
while(i*i<n):
if(n%i==0):
ans.append(i)
n=n//i
if(len(ans)==2 and n not in ans):
ans.append(n)
break
i+=1
if(len(ans)==3):
print("YES")
print(*ans)
else... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for i in range(int(input())):
n = int(input())
f = []
for j in range(2, int(n**(1/2))):
while n % j == 0:
f.append(j)
n = int(n/j)
if n > 1:
f.append(n)
if len(f) >= 3:
if len(f) == 3:
if f[0] != f[1] and f[1] != f[2] and f[2] != f[0]:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
import java.io.*;
public class Main {
static final long M = 1000000007;
static FastReader in = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
// static Scanner in = new Scanner(System.in);
// File file = new File("input.txt");
// Scanner in = new Scanner... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int cases;
cin >> cases;
for (int tt = 0; tt < cases; tt++) {
long long n;
cin >> n;
int ok = 0;
long long ax, ay, az;
for (long long i = 2; i * i <= n && !ok; i++) {
if (n % i == 0) ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long t = sc.nextLong();
while(t>0){
long n = sc.nextLong();
long a[] = new long[3];
int cnt = 0;
for(long i=2;i*i<n;i++){
if(n%i==0){
a[0] = i;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for i in range(int(input())):
a=int(input())
r=0
b=1
while(1):
p=0
for j in range(b+1,a+1):
if a//j<=j:
p=1
break
else:
if a%j==0:
if r==1:
c=j
d=a//j
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def product(n):
for i in range(2,int(n**(1/3))+1):
if n%i==0:
for j in range(i+1,int((n)**(1/2))):
if (n//i)%j==0 and j!=i and (n//i)/j!=i and j!=(n//i)**(1/2):
print("YES")
print(i,j,(n//i)//j)
return
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)... | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 3 10:55:17 2020
@author: Krishna
"""
import math
t=int(input())
for _ in range(t):
n=int(input())
m=n
d={}
while n%2==0:
if 2 not in d:
d[2]=1
else:
d[2] += 1
n=n/2
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)... | t=int(input())
for _ in range(t):
n=int(input())
ad=False
for i in range(2,10001):
if (n%i==0):
ln1=n//i
n1=i
#print("n1 = ",n1)
for j in range(i+1,10001):
#print("ln1(rem)j = ",ln1%j)
if (ln1%j==0 and j*j!=ln1 and ln1//j!=i and ln1//j!=1):
ln2=ln1//j
n2=j
n3=ln2
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 math
if __name__ == "__main__":
t = int(input())
for _ in range(t):
n, a, b = int(input()), 0, 0
i = 1
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0 and i != n // i:
n, a = n // i, i
break
for j in range(i, int(math.sq... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def p(n) :
l=[]
i = 1
while i <= math.sqrt(n):
if (n % i == 0) :
if (n / i == i) :
if(i!=1):
l.append(i)
else :
if(i!=1):
l.append(i)
if(n//i!=1):
l.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)... | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
for j in range(cnt):
arr.append(i)
if temp != 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 sys
import math
import collections
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(int(input())):
n=int(input())
p=0
for i in range(2,... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | //package codeforces;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.util.TreeMap;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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())
x=int(n)
v=2
k=0
t=[]
while n>v*v and k<2:
if n%v==0:
t.append(v)
k+=1
n=n//v
v+=1
if len(t)<2:
print("NO")
else:
k=x//(t[0]*t[1])
if k==t[0] or k==t[1]:
print("NO")
else:
print("YES")
print(t[0],t[1],x//(t[0]*t[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)... | from math import sqrt
t=int(input())
while t:
n=int(input())
nn=n
nnn=n
num=[]
n=int(sqrt(n))+1
cou=0
if(nn%2==0):
cou+=1
num.append(2)
while nn%2==0:
nn=nn//2
for i in range(3,n,2):
if(cou==3):
break
if(nn%i==0):
cou+=1... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void add(long long int& a, long long int b) {
a += b;
while (a >= mod) a -= mod;
while (a < 0) a += mod;
}
void mul(long long int& a, long long int b) {
a *= b;
while (a >= mod) a -= mod;
while (a < 0) a += mod;
}
long long int binexp... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
for i in range(t):
n=int(input())
flag=0
a=[]
count=0
for j in range(2,31623):
if(n%j==0):
count+=1
a.append(j)
n=n//j
if(count==2):
if(a[0]!=n and a[1]!=n and n!=1):
flag=1
a.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)... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
char c = getchar();
int x = 0, f = 1;
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
const int maxn = 1e6 + 10;
const... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from bisect import *
from collections import *
def factorize(n): # o(sqr(n))
c, ans = 2, []
while (c * c < n):
if n % c == 0:
ans.append(c)
ans.append(n // c)
c += 1
if c * c == n:
ans.append(c)
return sorted(ans)
for i in range(int(input())):
n ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
public class Template implements Runnable{
public static void main(String args[] ) throws Exception {
new Thread(null, new Template(),"Main",1<<27).start();
}
public void run() {
InputReader in = new InputReader(System.in);
Prin... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from sys import stdin,stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda: list(map(int, stdin.readline().split()))
ei = lambda: map(int, stdin.readline().split())
ip = lambda: int(stdin.readline().strip())
def primeFacto... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 j in range(int(input())):
n=int(input())
flag = False
for i in range(2,int(n**(1/3))+1):
if n%i==0:
z=n//i
for k in range(i+1,int(z**0.5)+1):
if z%k==0 and k*k!=z:
flag=True
print("YES")
print(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import *
for _ in range(int(input())):
n = int(input())
ch1 = 1
ch2 = 1
a1 = 0
a2 = 0
a3 = 0
g = 0
for i in range(2,int(sqrt(n)+1)):
if(n%i == 0):
a1 = i
g = n//i
break
else:
ch1 = 0
if(ch1 == 1):
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
long long spf(long long n) {
if (n % 2 == 0) {
return 2;
}
while (n % 2 == 0) {
n /= 2;
}
for (long long i = 3; i * i <= n; i++) {
if (n % i == 0) {
return i;
}
}
return n;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(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 Template {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
int yo = sc.nextInt();
while (yo-- > 0) {
long n = sc.nextLong();
long a = 0, b = 0, c = 0;
boolean ok = false;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
const long double INF = 1e18 + 7;
long long N = 1e6 * 5;
long double EPS = 1 / 1e18;
long long a[1005];
map<long long, long long> cnt;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
for (long long i = 0; i < t; i++)... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import sqrt
n=int(input())
s = 32000
lst=[2]
for i in range(3, s+1, 2):
if (i > 10) and (i%10==5):
continue
for j in lst:
if j*j-1 > i:
lst.append(i)
break
if (i % j == 0):
break
else:
lst.append(i)
for i in range(n):
m=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())
for i in range(t):
n=int(input())
k1=int(pow(n,0.333))
k2=k1**2
a=0
b=0
s=n
for j in range(2,k1+1):
if(n%j==0):
a=j
n=n//j
break
if(a==0):
print ('NO')
continue
else:
k=int(pow(n,0.5))
for j 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
def calc(n: int):
myStack: list = [n]
for i in range(2, int(math.sqrt(myStack[-1])) + 1):
x, rem = divmod(myStack[-1], i)
if rem == 0:
myStack.pop()
myStack.append(i)
myStack.append(x)
break
else:
print('NO')
retu... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def primeFactors(n):
factors = []
while n % 2 == 0:
factors.append(2)
n = n // 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
factors.append(i)
n = n // i
if n > 2:
factors.append(n)
return factors
t=int(input())
for q 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)... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
public class First {
public static void main(String[] args) ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 find(n):
count=0
flag=0
ori=n
for i in range(2,int(math.sqrt(n))+3):
if(n%i==0):
count+=1
n=n//i
liste.append(i)
if(count>=2):
r=ori//(liste[0]*liste[1])
if(r!=liste[0] and r!=liste[1] and r!=1):
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... |
for i in range(int(input())):
n = int(input())
p=[]
m=2
while m*m<=n:
if n%m==0:
n=n//m
p.append(m)
if len(p)==2:break
m+=1
if len(p)<2:
print("NO")
elif p[0]!=p[1]!=n and n>2:
print("YES")
print(*p, n)
else:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.*;
import java.util.*;
import java.lang.*;
public class Codechef {
PrintWriter out;
StringTokenizer st;
BufferedReader br;
class Pair implements Comparable<Pair>
{
int x;
int y;
Pair(int t, int r) {
x = t;
y = r;
}
public int compareTo(Pair p)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for _ in range(int(input())):
n = int(input())
X = set()
x = 1
for d in range(2, 1+int(n**.5)):
while not n%d:
x *= d
n //= d
if len(X)<2 and x not in X:
X.add(x)
x = 1
X.add(n*x)
if len(X)<3 or 1 in X:
print('NO... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
import math
input=sys.stdin.readline
# A function to print all prime factors of
# a given number n
def primeFactors(n):
# Print the number of two's that divide n
while n % 2 == 0:
n = n / 2
return(2,n)
# n must be odd at this point
# so... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | # Unmesh Kumar
# IITR CSE '22
from math import *
for _ in range(int(input())):
n=int(input())
pos=False
for a in range(2,int(pow(n,1/3))+1):
if n%a==0:
z=n//a
for b in range(a+1,int(sqrt(z))+1):
if z%b==0 and b*b!=z:
pos=True
print('YES')
print(a,b,z//b)
break
if pos:
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.util.*;
import java.io.*;
public class Main {
static InputReader scn = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] HastaLaVistaLa) {
// Running Number Of TestCases (t)
int t = scn.nextInt();
while(t-- > 0)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
def f(a):
b=2
a=int(a)
fac=[]
c=math.sqrt(a)
while b<=c and a>1:
if a%b==0:
while a%b==0:
fac.append(b)
a/=b
b+=1
else:
b+=1
if a!=1:
fac.append(a)
return fac
for i in rang... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
from functools import reduce
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def factors(n):
return list(set(reduce(list.__add__,
([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def product():
for _ in range(t):
n=int(input())
yn=... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t = int(input())
while t>0:
# print("t: ",t)
t-=1
n = int(input())
num_factors=0
first_factor = -1
second_factor = -1
if n==1 or n==2:
print("NO")
continue
n_copy=n
s = int(math.sqrt(n))
for i in range(2,s):
if n_copy%i==0:
if fir... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
const int N = 1e5 + 7;
const int M = 1e6 + 7;
const int INF = 1e9 + 8;
int p[N];
int c[N];
int m;
void divide(int n) {
m = 0;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
p[++m] = i, c[m] = 0;
while... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N];
void solve() {
int n;
cin >> n;
set<int> s;
for (long long i = 2; i * i <= n; i++) {
if (n % i == 0 && s.find(i) == s.end()) {
n /= i;
s.insert(i);
break;
}
}
for (long long i = 2; i * i <= n; i++) {
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
for i in range(t):
n=int(input())
a=math.sqrt(n)
a=int(a)
c=[]
f=0
d=0
b=int(a)
for j in range(2,a+1,1):
if(n%j==0):
f=1
x=j
y=n//j
break
if(f==0):
print("NO")
else:
f=0
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | 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) {
int n = sc.nextInt();
int[] arr = new int[3];
int index=0, divisor=2;
while(n%divisor==0 && 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>
#pragma 03
using namespace std;
vector<pair<long long, long long> > pfac;
long long binpow(long long x, long long y) {
if (x == 0) return 0;
if (y == 0) return 1;
long long res = binpow(x, y / 2);
if (y % 2 == 0)
return res * res;
else
return res * res * x;
}
signed main() {
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t = int(input())
for i in range(t):
n = int(input())
f = 1
for a in range(2, int(math.sqrt(n)) + 1):
if f and n % a == 0:
curn = n // a
for b in range(2, int(math.sqrt(curn)) + 1):
if f and b != a and curn % b == 0:
c = curn // ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 facts(n):
l=[]
for i in range(2,int(pow(n,0.5))+1):
if n%i==0:
l.append(i)
l.append(n//i)
return list(set(l))
for _ in range(int(input())):
n=int(input())
l=facts(n)
l.sort()
d={}
for i in l:
d[i]=0
flag = 0
for i in range(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)... | # cook your dish here
import math
for t in range(int(input())):
n=int(input())
flag=False
for i in range(2,int(math.sqrt(n))+1):
if n%i==0:
x=i
yy=n//i
for j in range(i+1,int(math.sqrt(yy))+1):
if yy%j==0:
y=j
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
for i in range(t):
n=int(input())
k=n
l=[]
for j in range(2,int(math.sqrt(n))+1):
if n%j==0:
l.append(j)
break
if len(l)!=0:
n=n//l[0]
for j in range(2,int(math.sqrt(n))+1):
if n%j==0:
if j not in 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>
int n, a[105], m;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) {
int s1 = 0, s2 = 0, s3 = 0;
m = a[i];
for (int j = 2; j * j <= m; j++) {
if (m % j == 0) {
if (s1 == 0)
s1 = j;
else
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import *
from operator import *
def isPrime(x):
if(x in [1,4]):
return False
elif(x in [2,3,5]):
return True
else:
for i in range(2,int(sqrt(x))+1):
if(x%i == 0):
return False
return True
def Sieve(x):
checkPrime = [1 for i in range(x+1)]
zz = 2
L = []
while(zz**2 <= x):
if(checkPrim... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 P(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
t=int(input())
for i in range(t):
x=int(input())
p=P(x)
if len(p)>2:
a=p[0]
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n;
cin >> n;
long long int ans[3];
long long int count = 0;
for (long long int i = 2; i * i <= n; i++) {
if (n % i == 0) {
n = n / i;
ans[count] = i;
count++;
}
if (count == 3) {
break;
}
}
i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n, a, b, i, ra, rb, rc;
cin >> t;
while (t--) {
ra = rb = rc = 1;
cin >> a;
b = sqrt(a);
for (i = 2; i <= b + 1; i++) {
if (a % i == 0) {
a = a / i;
ra = i;
break;
}
}
b = sqrt(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 math
def isPrime(n) :
if (n <= 1) :
return False
if (n <= 3) :
return True
if (n % 2 == 0 or n % 3 == 0) :
return False
i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return False
i = i + 6
return True
t=int(inp... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | # your code goes here
import math
t=int(input())
while(t>0):
n=int(input())
l=[]
c=0
s=int(math.sqrt(n))
for i in range(2,s+1):
if(n%i==0):
l.append(i)
c+=1
n=n//i
break
for i in range(2,s+1):
if(i not in l and n%i==0):
l.append(i)
c+=1
n=n//i
break
if(c<2 or n==1 or n in l):
print(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for _ in range(int(input())):
n=int(input())
a=0
b=0
c=0
for i in range(2,int(n**0.5)+1):
if n%i==0:
a=i
t=n//i
for j in range(a+1,int(t**0.5)+1):
if t%j==0:
b=j
c=t//j
if 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)... |
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class T {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int c=0;
int c1=0;
int c2=0;
int c3=0;
boolean t ;
for(int i =... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def miller_rabin_primalitytest(n,a):
z=n-1
d=z
while(d%2==0):
d=d//2
if(pow(a,d,n)!=1):
x=d
while(x<n):
r=pow(a,x,n)
if(r==n-1):
return "Probable Prime"
else:
x=2*x
return "Composite"
else:
return "Probable Prime"
def isprimeoptimized(n):
if(n%2==0 and n>2):
return False
elif(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)... | q = int(input())
def div_by_primes(n):
p = []
s = []
for d in range(2, int(n**(1/2))+1):
if n%d == 0:
p.append(d)
s.append(0)
while n%d == 0:
s[-1] += 1
n //= d
if n > 1:
p.append(n)
s.append(1)
return p, s
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.*;
import java.util.*;
public class C {
public static boolean[] isPrime;
public static void main(String[] args) {
FastScanner sc=new FastScanner();
int t = sc.nextInt();
isPrime = new boolean[1000007];
fillPrime();
while(t-->0) {
int n = sc.nextInt();
if(n< 1000007 && isPrime[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
class Read:
@staticmethod
def int():
return int(input())
@staticmethod
def list(sep=' '):
return input().split(sep)
@staticmethod
def list_int(sep=' '):
return list(map(int, input().split(sep)))
def main():
n = Read.int()
status = False
for... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
for i in range(t):
n = int(input())
Ans = []
d = 2
while d * d <= n:
if n % d == 0:
Ans.append(d)
break
else:
d += 1
if len(Ans) == 0:
Ans.append(n)
n //= Ans[-1]
while d * d <= n:
if n % d == 0 and Ans[-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
ts = int(input( ))
while ts > 0:
ts = ts - 1
n = int(input( ))
flag = 0
a, b, c = 0, 0, 0
for i in range( 2, int(math.sqrt(n) + 1 ) ):
if n % i == 0:
a = i
n = int( n / a )
break
for i in range( 2, int(math.sqrt(n) + 1 ) ):
if n % i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int T;
int main(int argc, char const *argv[]) {
cin >> T;
for (int kase = 1; kase <= T; kase++) {
int n;
cin >> n;
map<int, int> mp;
int tmp = n;
int cnt = 3;
while (cnt) {
if (cnt == 1) {
mp[tmp] = 1;
break;
}
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)... | for _ in " "*int(input()):
n=int(input());a=[];i=2
while(len(a)<2 and i*i<n):
if n%i==0:n=n//i;a.append(i)
i+=1
if len(a)==2 and n not in a:print("YES");print(n,*a)
else:print("NO")
|
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def factors(x):
result = []
i = 1
while i*i <= x:
if x % i == 0:
result.append(i)
if x//i != i: #
result.append(x//i)
i += 1
return(result)
for _ in range(int(input())):
n = int(input())
lst = sorted(factors(n))
a = lst[1]
x = 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)... | import math
def div(n, m):
i = m+1
while i*i < n:
if(n%i == 0):
return(i, n // i)
i += 1
return(-1, -1)
t = int(input())
for _ in range(t):
n = int(input())
a = 0
i = 2
while i * i < n:
if (n % i == 0):
a = i
break
i += ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int gcd(int r, int p) {
if (p == 0) return r;
return gcd(p, r % p);
}
struct Test {
int x, y, z;
};
long long int fact(long long int x) {
long long int p = (fact(x - 1) * x) % 1000000007;
return p;
}
void sieveOfEratosthenes(long long int N, long long int s[]) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.