description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | n=int(input())
s=list(input())
c=s.copy()
k=[]
for i in range(n-1):
if s[i]=='W':
pass
else:
s[i]='W'
if s[i+1]=='W':
s[i+1]='B'
else:
s[i+1]='W'
k.append(i+1)
if s==['W']*n:
print(len(k))
print(*k)
else:
s=c.copy()
k=[]
for i i... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | def sol():
n = int(input())
s = list(input())
b = s.count('B')
w = s.count('W')
if w % 2 == 1 and b % 2 == 1:
print(-1)
return
ans = []
s = list(s)
if w % 2 == 1:
odd = 'W'
even = 'B'
else:
odd = 'B'
even = 'W'
for i in range(n-1):
if s[i] != odd:
ans.append(i + 1)
... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... |
import java.io.BufferedReader;
import java.io.Console;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static int check(StringBuffer sf) {
int B = 0, W ... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | n=int(input())
s=list(input())
ans=[]
if s[0]=="W":
ans.append(0)
s[0]="B"
if s[1]=="W":
s[1]="B"
else:
s[1]="W"
for i in range(1,n-1):
if s[i]=="W":
s[i]="B"
if s[i+1]=="W":
s[i+1]="B"
else:
s[i+1]="W"
ans.append(i)
if s!=["B" ... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | def solve():
n = int(input())
s = input()
ans = 0
res = []
w = 0
b = 0
for i in range(n):
if s[i]=="W":
w+=1
if s[i]=="B":
b+=1
delta = -1
if w==0 or b==0:
print(0)
return
if w%2==1:
if b%2==1:
print(-1... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | n=int(input())
s=input()
l=[i for i in s]
s=list(l)
numofb=0
numofw=0
for i in s:
if(i=='B'):
numofb+=1
else:
numofw+=1
c=0
if(numofb%2==0):
c='W'
elif(numofw%2==0):
c='B'
if(c==0):
print(-1)
else:
numofs=0
l=[]
for i in range(n-1):
if(s[i]!=c):
if(s[... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | def change(a):
if a == 'W':
return 'B'
else:
return 'W'
n = int(input())
ss = input()
s = []
s[:0] = ss
ops = []
good = "w"
if s.count("B") == 0 or s.count("W") == 0:
print(0)
# print("uff")
exit()
elif s.count("B") % 2 == 0:
good = "W"
elif s.count("W") % 2 == 0:
good = "B"... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | #include <bits/stdc++.h>
using namespace std;
template <class C>
void min_self(C &a, C b) {
a = min(a, b);
}
template <class C>
void max_self(C &a, C b) {
a = max(a, b);
}
long long mod(long long n, long long m = 1000000007) {
n %= m, n += m, n %= m;
return n;
}
mt19937 rng(chrono::steady_clock::now().time_sinc... |
There are n blocks arranged in a row and numbered from left to right, starting from one. Each block is either black or white.
You may perform the following operation zero or more times: choose two adjacent blocks and invert their colors (white block becomes black, and vice versa).
You want to find a sequence of ope... | #include <bits/stdc++.h>
using namespace std;
vector<int> v;
bool conv(string s, char w) {
v.clear();
for (int i = 0; i < s.size(); i++) {
if (s[i] == w)
continue;
else if (i != s.size() - 1) {
v.push_back(i + 1);
if (s[i + 1] == 'W')
s[i + 1] = 'B';
else
s[i + 1] = '... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args) throws Exception {
IO io = new IO();
PrintWriter out = new PrintWriter(System.out);
Solver sr = new Solver();
sr.solve(io,out);
out.flush();
out.close();
}
static class Solver
{
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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=1
c=2
l=[]
y=n
while(i<=2):
if n%c==0:
n=n//c
i=i+1
l.append(c)
if c>=y**0.5:
break
c=c+1
if l==[] or len(l)==1:
print("NO")
elif y%(l[0]*l[1])==0:
x=y//... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | T = int(input().strip())
import math
for t in range(T):
N = int(input().strip())
status = True
for a in range(2, int(math.sqrt(N)+1)):
if N%a==0:
b=N//a
for x in range(2, int(math.sqrt(b)+1)):
if x!=a and b%x==0 and a!=b//x and x!=b//x:
pr... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
int main(void) {
long long t;
scanf("%lld", &t);
long long num, sub_num, i, j;
while (t--) {
int cnt = 1;
scanf("%lld", &num);
for (i = 2; (i * i) <= num; ++i) {
if (!cnt) {
break;
}
if (!(num % i)) {
sub_num = (num / i);
for (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)... | def factors(n):
s=[]
i=2
while(i*i<=n):
if(n%i==0):
s.append(i)
n=n//i
if(len(s)==2):
if(n not in s):
s.append(n)
break
i=i+1
if(len(s)<3):
print("NO")
else:
print("YES")
print(*s)
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().strip())
import math
def primeFactors(n):
ans = []
# Print the number of two's that divide n
while n % 2 == 0:
ans.append(2)
n = n // 2
# n must be odd at this point
# so a skip of 2 ( i = i + 2) can be used
result = int(math.sqrt(n))
f... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for _ in range(int(input())):
n = int(input())
if n < 24:
print("NO")
continue
j = -1
a, b = 0, 0
for i in range(2, int(n**(1 / 3)) + 1):
if n % i == 0:
a = i
n //= i
j = i + 1
break
if j == -1:
print("NO")
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 math
from collections import defaultdict
def primeFactors(n):
d=defaultdict(int)
while n % 2 == 0:
d[2]+=1
n = n // 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
d[i]+=1
n = n / i
if n > 2:
d[n]+=1
return d
t=int(input())
for i in range(t):
n=int(input())
d=... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | # from debug import debug
import sys
t_ = int(input())
while t_:
t_-=1
n = int(input())
if n<24:
print("NO")
else:
i = 2
a = b = c = 0
while i*i<n:
if n%i == 0:
a = i
n = n//i
break
i+=1
if a == 0:
print("NO")
else:
i = 3
while i*i<n:
if n%i == 0 and i != a:
b = i
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
int tst;
long long n, a, b, c;
vector<long long> v;
bool flag;
cin >> tst;
while (tst--) {
flag = false;
cin >> n;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
v.push_back(i);
n /= i;
}
if (v.s... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long temp = n;
vector<long long> v;
for (long long i = 2; i <= sqrt(n); i++) {
while (n % i == 0) {
v.push_back(i);
n /= i;
}
}
if (n != 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 collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def tinput():
return input().split()
def... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | 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(set(ans))==3:
return ans
ans=[]
elif p==2 and n//i>1:
new=ans+[(n//i),i]... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
for _ in range(int(input())):
n=int(input())
g=0
for i in range(2,math.floor(math.sqrt(n))+1):
if n%i==0:
if n//i!=i:
p=n//i
for j in range(2,math.floor(math.sqrt(i))+1):
if i%j==0:
if i//j!=j and j!=... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
bool isPrime(int x) {
for (long long int i = 2; i * i <= x; i++) {
if (x % i == 0) return false;
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int aux;
cin >> aux;
while (aux--) {
int n;
cin >> n;
int num = 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;
struct di {
int div1, div2;
};
struct divv {
int divv1, divv2, divv3;
};
di a = {0, 0};
divv b = {0, 0, 0};
int n, t;
di f(int nr) {
for (int d = 2; d * d <= nr; d++)
if (nr % d == 0) {
di x = {d, nr / d};
return x;
}
return a;
}
divv esteprod(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)... | N = int(input())
for _ in range(N):
x = int(input())
d = 2
ans = []
for steps in range(2):
if d > x:
break
while d * d <= x:
if x % d == 0:
ans.append(d)
x //= d
d += 1
break
d += 1
i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | ### C. Product of Three Numbers
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+=1
if len(c)==2 and n not in c:
print('YES')
print(*c,n)
else:
print('NO') |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
for i in range(t):
n=int(input())
f=0
l=[]
l1=[]
for j in range(2,int(math.sqrt(n))+1):
if n%j==0:
l.append(j)
l.append(n//j)
l1=list(set(l))
l1.sort()
if len(l1)==0:
print("NO")
else:
a=l1[0]
n=n//a
for j in range(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def solve(n,i):
a=-1
b=-1
while (i*i<=n):
if (n%i)==0:
a=i
b=n//i
if a==b:
a=-1
b=-1
break
i+=1
return a,b
for t in range(int(input())):
n =int(input())
a,b = solve(n,2)
if a==-1:
print("NO")
else:
b,c = solve(b,a+1)
if b==-1:
print("NO")
else:
print("YES")
print(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 atexit, io, sys, collections, math, heapq, fractions
buffer = io.BytesIO()
sys.stdout = buffer
@atexit.register
def write(): sys.__stdout__.write(buffer.getvalue())
####################################
def f(n):
u = 2
on = n
r = []
limit = int(on **0.5)
whil... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
const long long int mod = 1e9 + 7;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
;
long long int t = 0;
cin >> t;
while (t--) {
long long int n = 0;
cin >> n;
if (n < 24) {
cout << "NO\n";
continue;
} else {
vector<long... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from sys import stdin
t = int(stdin.readline())
for _ in xrange(t):
n = int(stdin.readline())
a = []
i = 2
while True:
if i * i > n:
break
if n%i==0:
a.append(i)
n/=i
i+=1
break
i+=1
while True:
if i*i > n... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for _ in range(int(input())):
n = int(input())
i = 2
while i * i <= n:
if n % i == 0:
k = n // i
j = i + 1
fl = 0
while j * j <= k:
if k % j == 0 and j != k // j:
print("YES")
print(i, j, k // j)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | """
author : dokueki
"""
import math
def divisor(x):
i = 1
div = []
while i <= math.sqrt(x):
if x%i == 0:
if x//i == i:
div.append(i)
else:
div.extend([i,x//i])
i += 1
div.remove(max(div))
div.remove(min(div))
return div
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
#sys.stdin = open("division.in","r")
#sys.stdout = open("division.out","w")
t = int(input())
for i in range(t):
n = int(input())
i = 2
flag = 0
while(i ** 2 <= n):
if n % i == 0:
a = i
j = 2
while(j ** 2 <= (n // a)):
if (n // a) % j... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in 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 math
for _ in range(int(input())):
n = int(input())
a = b = c = -1;
ok = 0;
for j in range(2, int(math.sqrt(n))+1):
if n % j == 0:
if a == -1:
a = j;
n /= a
elif b == -1:
b = j;
n /= b;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for i in range(int(input())):
k=set()
a=int(input())
for i in range(2,10000):
if len(k)<2:
if a%i==0:
a=a//i
k.add(i)
elif len(k)==2 and a>2:
k.add(a)
if len(k)==3:
print('YES')
for i in sorted(k):
print(i,end=' ')
print()
else:
print('NO') |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.ArrayList;
import java.util.Scanner;
public class ProductofThreeNumbers {
public static ArrayList<Integer> factors;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0) {
int n = in.nextInt();
getFactors(n);
//brute 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)... | def primefactor(n):
l = []
while n%2==0:
l.append(2)
n = n//2
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:
l.append(i)
n//=i
if n>2:
l.append(n)
return l
for _ in range(int(input())):
n = primefactor(int(input()))
l = []
if len(n)==3:
if len(set(n))==3:
print("YES")
print(*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.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a[]=new int [(int)5e4+10];
ArrayList<Integer> al=new ArrayList<Integer>();
Arrays.fill(a,1);
for(int i=2;i<a.length;i++) {
if... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
t=int(input())
for _ in range(t):
n=int(input())
n_root=int(math.sqrt(n))
ans=[]
count=0
for i in range(2,n_root+1):
if n%i==0:
ans.append(i)
count+=1
n//=i
if count==2 and n>ans[-1]:
count+=1
ans.append(n)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
for _ in range(int(input())):
n=(int(input()))
f=0
s=0
k=0
if(n<24):
f=1
else:
for i in range(2,int(math.sqrt(n))+1):
if(n%i==0):
f=0
k=i
break
if(k==int(math.sqrt(n))):
f=1
#print(f)
if(n>=24 and f==0):
f=1
for i in range(2,int(math.sqrt(n))+1):
i... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.io.PrintWriter;
import java.util.*;
public class TP {
public static PrintWriter out = new PrintWriter(System.out);
public static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
long s = System.currentTimeMillis();
int t = 1;
t = ni();
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 pro(j):
for a in range(2,int(j**(1/3))+1):
if j%a==0:
for b in range(a+1,int(j**(1/2))):
if (j//a)%b==0 and (j//a)//b!=a and ((j//a)//b)!=int((j//a)**(1/2)):
print("YES")
print(a,b,(j//a)//b)
return
print("NO")
r... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
public class ProductOfThreeNumbers{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
long n=sc.nextLong();
long arr[]=new long[3];
int c=0;
for(int j=2;j<=M... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def main():
n = int(input())
a = 2
while a * a * a < n:
if n % a == 0:
b = a + 1
while b * b < n // a:
if (n // a) % b == 0:
c = n // a // b
if a != c and b != c:
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)... | def factor(n):
ans=[]
d=2
while d*d<=n:
if n%d==0:
ans.append(d)
n=n//d
else:
d+=1
if n>1:
ans.append(n)
return ans
t=int(input())
for i in range(t):
n=int(input())
ans=factor(n)
if len(ans)<3:
print("NO")
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 _ in range(int(input())):
n = int(input())
c = 0
a = []
for i in range(2, int(n**0.5)+1):
if n % i == 0:
a.append(i)
n = n//i
if len(a) == 2:
break
if len(a) == 2 and n > a[1]:
print('YES')
print(a[0],a[1],n)
else:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v;
for (int i = 2; i <= sqrt(n); i++) {
while (n % i == 0) {
v.push_back(i);
n /= i;
}
}
if (n > 1) v.push_back(n);
set<int> s;
int cur... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 de(m):
ret = []
n = m
for i in range(2,int(math.sqrt(n))+1):
while n%i == 0:
ret.append(i)
n/= i
if n!= 1:
ret.append(n)
return ret
def solve(n):
lst = de(n)
args = list(set(lst))
if len(args) >= 3:
print "YES"
print args[0],args[1],n/args[0]/args[1]
elif len(args) == 2:
if ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | n=int(input())
for i in range(n):
num=int(input())
list1=[]
j=2
while(j*j<num and len(list1)<2):
if(num%j==0):
num=num//j
list1.append(j)
j+=1
if(len(list1)==2 and num not in list1):
print("YES")
for k in list1:
print(k,end=" ")
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | ''' Hey stalker :) '''
INF = 10**10
def main():
#print = out.append
''' Cook your dish here! '''
n = get_int()
factors = prime_factors(n)
keys = list(factors.keys())
if len(factors)>=2:
a, b = keys[:2]
c = n // (a * b)
if c==a or c==b or c<2:
print("NO")
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
void fastIo() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
const long long N = 100000;
bitset<N + 5> p;
vector<long long> primes;
void spf() {
primes.push_back(2);
for (int i = 4; i <= N; i += 2) p[i] = 1;
for (long long i = 3; i <= N; i += 2) {
if (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)... | '''
5
64
32
97
2
12345
'''
def mi():
return map(int, input().split())
for _ in range(int(input())):
n = int(input())
i = 2
found=0
while i*i<=n:
if (n % i == 0):
n1 = n//i
j=2
comp=0
while j*j<=n1:
if n1%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)... | for _ in range(int(input())):
n=int(input())
ans=[]
for i in range(2,n):
if i*i>=n: break
if n%i==0:
ans.append(i)
n//=i
if len(ans)==2:
ans.append(n)
break
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)... | import java.io.PrintWriter;
import java.util.Scanner;
public class ProductOfThreeNumbers {
public static Scanner sc = new Scanner(System.in);
public static PrintWriter out = new PrintWriter(System.out, true);
public static int n;
public static void Input() {
n = sc.nextInt();
}
public static int sma... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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
def Prime(d, n):
if n%d == 0:
return d
while d * d <= n:
if n % d == 0:
return d
d= d + 1
return 0
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
if n < 24 :
print("NO")
continue
ans = []
count = 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 sys
I=sys.stdin.readline
ans=""
for _ in range(int(I())):
n=int(input())
fac=[]
for i in range(2,int(n**.5)):
if n%i==0:
fac.append((i,n//i))
break
#print(fac)
if len(fac)!=0:
x=fac[0][1]
flag=1
for i in range(2,int(x**.5)+1):
if x%i==0 and i!=fac[0][0]:
if i!=x//i:
ans+="YES\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;
int main() {
int t;
cin >> t;
for (int g = 0; g < t; ++g) {
int n;
cin >> n;
vector<int> v;
for (int i = 2; i <= int(sqrt(n)); ++i) {
if (n % i == 0) {
v.push_back(i);
v.push_back(n / i);
}
}
bool T = 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)... | /*
javac c.java && java c
*/
import java.io.*;
import java.util.*;
public class c {
public static void main(String[] args) { new c(); }
FS in = new FS();
PrintWriter out = new PrintWriter(System.out);
int t;
int n;
c() {
t = in.nextInt();
while (t-- > 0) {
n = in.nextInt();
int[] ans = new int[3];
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def isPrime(n):
if n == 2 or n == 3: return True
if n % 2 == 0 or n < 2: return False
for i in range(3, int(n ** 0.5) + 1, 2):
if n % i == 0:
return False
return True
t = int(input())
for _ in range(t):
f = 0
n = int(input())
if isPrime(n):
print("NO")
continue
f... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for 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 and n not in c:
print("YES")
print(*c,int(n))
else:
print("NO") |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | #include <bits/stdc++.h>
using namespace std;
long long ans[3];
int main() {
int t;
cin >> t;
long long n;
for (int o = 0; o < t; o++) {
cin >> n;
vector<long long> z;
long long r = sqrt(n) + 1;
for (long long i = 2; i <= r; i++) {
{
while (n % i == 0) {
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())
q = int( math.sqrt(n))
l = set()
for j in range(2, q + 1):
if n % j == 0:
l.add(j)
if len(l) < 2:
print('NO')
else:
l = sorted(list(l))
res = False
for k in range(len(l) - 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 collections import defaultdict
for _ in range(int(input())):
n = int(input())
dr = n
i = 2
primes = defaultdict(int)
while i * i <= n:
while dr % i == 0:
primes[i] += 1
dr //= i
i += 1
if dr != 1:
primes[dr] += 1
if len(primes) >= 3:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
def primes(n):
while n % 2 == 0:
prime.append(2)
n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
while n % i == 0:
prime.append(i)
n = n / i
if n > 2:
prime.append(int(n))
t=int(input())
for _ in ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
public class CodeForces1294C{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for(int j = 0;j<t;j++){
int n = input.nextInt();
ArrayList<Integer> arr = new ArrayList<>();
int m = n;
for(int i = 2;i<=Math.sqrt(m);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 floor, sqrt, ceil
def findPrimeFac(num):
ans = []
lim = ceil(sqrt(num))
while num % 2 == 0:
ans.append(2)
num //= 2
for p in range(3, lim, 2):
while num % p == 0:
ans.append(p)
num //= p
if num != 1:
ans.append(num)
return ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import sqrt
def szuk_podz(liczba, a = 1):
for x in range(2, int(sqrt(liczba)) + 1):
if liczba % x == 0 and x != a:
return x
return -1
for _ in range(int(input())):
n = int(input())
a, b, c = szuk_podz(n), 0, 0
x = n // a
if a == -1:
print("NO")
conti... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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 kek in range(t):
n = int(input())
i = 2
s = list()
while i < n ** (1 / 2) + 1:
if n % i == 0:
s.append(i)
n //= i
else:
i += 1
if n != 1:
s.append(n)
a = list()
a.append(s[0])
x = 1
for i in range(1, le... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
for _ in range(t):
out = []
n = int(input())
d = 2
while d * d <= n:
if n % d == 0:
out.append(d)
n //= d
if len(out) == 2:
break
d += 1
if len(out) == 2 and n > out[1]:
print("YES")
print(out[0], o... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for xyz in range(t):
n=int(input())
a=[]
fa=1
p=n
i=2
while(i*i<=p):
if p%i==0 and i not in a:
a.append(i)
p=p/i
break
i=i+1
while(i*i<=p):
if p%i==0 and i not in a:
a.append(i)
p=p/i
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import os,sys,math,random
def dep(a):
a0 = a
res = []
for b in range(2, int(a**(1/3))+1):
if a % b == 0:
res.append(b)
break
if len(res) == 0:
return "NO"
a /= res[0]
for b in range(2, int(a**(1/2))+1):
if a % b == 0 and b != res[0]:
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from collections import defaultdict
import math
def prime(n):
ans=[]
al=defaultdict(int)
while(n%2==0):
al[2]=al[2]+1
ans.append(2)
n=n//2
for i in range(3,int(math.sqrt(n))+1,2):
while(n%i==0):
al[i]+=1
ans.append(i)
n=n//i
if(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | # Enter your code here. Read input from STDIN. Print output to STDOUT# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import Byt... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 22 18:45:17 2020
@author: npuja
"""
"""
t=int(input())
for i in range(0,t):
a,b,c,n=(int(k) for k in input().split())
mac=0
if a>=b and a>=c:
mac=a
elif b>=a and b>=c:
mac=b
else:
mac=c
test=n-3*(mac)+a+b+c
if test<0 or ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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.text.*;
import java.util.*;
public class Solution{
BufferedReader br;
PrintWriter out;
static String input[];
static int id = 0;
public String next() throws Exception{
if(input == null || input.length == id){
input = br.readLine(... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def product_of_3_numbers(n):
for i in range(2, int(n ** (1 / 2)) + 1):
if n % i == 0:
d = n // i
for j in range(i + 1, int(d ** (1 / 2)) + 1):
if d % j == 0 and j != d // j:
print("YES")
print(i, j, d // j)
r... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().spli... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from collections import defaultdict as dd
from sys import stdin
input=stdin.readline
for _ in range(int(input())):
n=int(input())
br=0
for i in range(2,int(n**.5)+1):
fl=0
if n%i==0:
fl=1
x=i
for j in range(2,int(i**.5)+1):
if i%j==0 and le... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | for i in range(int(input())):
n = int(input())
ans = []
o = 0
for i in range(2,int(n**0.5)+1):
if n % i == 0:
if n//i == i:
continue
ans.append(i)
o = n//i
break
for i in range(2,int(o**0.5)+1):
if o % i == ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
def yes(factors):
print('YES')
print(' '.join(map(str, factors)))
def no():
print('NO')
for _ in range(t):
temp = n = int(input())
factors = []
i = 2
found = False
while(i <= pow(n, 1/2)):
while(n % i == 0):
if len(factors) == 0 or i not in factors[-1]:
factors.append({i:1})
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.util.ArrayList;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class Codechef {
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();
ArrayList<Inte... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import java.util.*;
import java.io.*;
public class ProductofThreeNumbers
{
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int T=Integer.parseInt(br.readLine());
while(T-->0)
{
int 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;
const int mod = 1e9 + 7;
const long long inf = 5e18;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
;
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
vector<long long> a;
for (long long i = 2; i <= min(100000ll,... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import sys
input = sys.stdin.readline
def find(n,fa,fb):
f = 2
while f*f <= n:
if n % f == 0 and f != fa and f != fb:
return f
f += 1
return n
for _ in xrange(int(input())):
n = int(input())
nn = n
fa = find(n,None,None)
n = n // fa
fb = find(n,fa, None)
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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(num):
isSimple = True
k = 0
while k < arr.__len__() and arr[k] <= math.sqrt(num):
if num % arr[k] == 0:
isSimple = False
num = num / arr[k]
break
k += 1
return num
import math
n = int(input())
arr = []
root = math.sqrt(1000000000)
for num 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;
void solve(long long N) {
vector<pair<long long, long long>> factors;
long long n = N;
for (long long i = 2; i * i <= n; i++) {
long long cnt = 0;
if (n % i == 0) {
while (n % i == 0) {
cnt++;
n /= i;
}
factors.push_back({i, 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.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(in.readLine());
for(int rc=0; rc<t; rc++) {
int n = Integer.par... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can 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, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in 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.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.util.*;
import java.lang.*;
import java.util.HashMap;
import java.util.PriorityQueue;
public class Solution implements Runnable
{
static class pair implements Comparable
{
int f;
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from math import ceil, sqrt
def main():
t = int(input())
while t:
n = int(input())
findProd(n)
t -= 1
def findProd(n):
a = 2
found = 0
temp = n
while a <= ceil(sqrt(n)):
if n%a == 0:
n = n // a
b = a + 1
while b <= ceil(sqrt(n)):
c = n//b
if n%b == 0 and c > 1 and c != b and c != 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;
bool isPrime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
int main() {
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
if (isPrime(n)) {
cout << "NO" << endl;
} else {
vector<int> f... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t = int(input())
for _ in range(t):
n = int(input())
f = 0
for i in range(2, int(n**0.5)+1):
if n % i == 0:
a = i
k = n // a
for j in range(2, int(k ** 0.5)+1):
if k % j == 0 and j != a and k // j != a and j != k // j:
b = j
... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | def factors(n):
factor = []
for i in range(2, int(n**0.5)+1):
if n % i == 0:
factor.append(i)
return factor
t = int(input())
for l in range(t):
n = int(input())
x = 0
factor = factors(n)
lenfactor = len(factor)
for i in range(lenfactor):
for j in range(i+1, ... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | from sys import stdin,stdout
from math import sqrt
from collections import Counter
primes,primes_list = set([2]),None
composites = set()
def gen_primes(n):
for i in range(3,n+1,2):
if i not in composites:
primes.add(i)
for j in range(i*2,n+1,i):
composites.add(j)
d... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | t=int(input())
for i in range(t):
n=int(input())
def check(n):
use=set()
i=2
while i*i<=n:
if n%i==0 and i not in use:
use.add(i)
n/=i
break
i+=1
i=2
while i*i<=n:
if n%i==0 and i not 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)... | from math import sqrt
def divide(n, start):
for k in range(start, int(sqrt(n)) + 1):
if n % k == 0:
return k
return n
for _ in range(int(input())):
n = int(input())
a = divide(n, 2)
if a == n:
print('NO')
continue
n //= a
b = divide(n, a + 1)
if b =... |
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 100)... | import math
from collections import defaultdict as dq
def primeFactors(n):
d=dq(int)
while n % 2 == 0:
d[2]+=1
n = n // 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
d[i]+=1
n = n // i
if n>1:
d[n]+=1
return d
for _ in range(int(input())):
n=int(input())
s=primeFactors(n)
if ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.