Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <vector>
using namespace std;
vector<int> res;
void Prime_factorize(int n){
for(int i = 2 ; i*i <= n ; i++){
while(n%i==0){
res.push_back(i);
n /= i;
}
}
if(n != 1) res.push_back(n);
}
int main(){
int n;
cin >> n;
cout << n << ':';
Prime_factorize(n);... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
int n;
cin >> n;
cout << n << ":";
while (n > 1) {
// 約数を探す
const double sqrtn = sqrt(n);
for (int i=2; i<=sqrtn; i++) {
if (n % i == 0) {
// iが約数
cout << " " << i;
n /= i;
goto LAST;
}
}
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
m = int(n**0.5)+2
is_prime = [1]*m
is_prime[0] = is_prime[1] = 0
for p in range(2,m):
for q in range(2*p,m,p):
is_prime[q] = 0
primes = [p for p, c in enumerate(is_prime) if c]
print(str(n)+': ', end='')
ans = []
for p in primes:
while n % p == 0:
ans.append(p)
n //= p
... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
print("{}:".format(n), end="")
q = 2
while n>1 and q*q <= n:
if n % q == 0:
print(" {}".format(q), end="")
n //= q
else:
q += 1
if n>1:
print(" {}".format(n), end="")
print("")
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringBu... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <stdio.h>
int main(void)
{
int n;
int i;
scanf("%d", &n);
printf("%d:", n);
for (i = 2; i * i <= n; i++){
while (n % i == 0){
printf(" %d", i);
n /= i;
}
}
if (n != 1){
printf(" %d", n);
}
printf("\n");
return (0);
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
m = n
output = []
for i in range(2, int(n**0.5)+1):
while True:
if n % i != 0:
break
else:
output.append(i)
n //= i
if n != 1:
output.append(n)
print(str(m) + ": " + ' '.join(map(str, output)))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n, m;
cin >> n;
m = n;
cout << n << ":";
for(int i = 2;i * i <= m;i++){
while(!(n % i)){
cout << " " << i;
n /= i;
}
}
if(n != 1) cout << " " << n;
cout << endl;
return 0;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | # coding: utf-8
# 73
n = int(input())
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
print(n,end='')
pr... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
ll n,tmp,i;
vector<ll> ans;
cin >> n;
tmp=n;
for(i=2;i*i<=n;i++){
while(n%i==0){
ans.push_back(i);
n/=i;
}
}
if(n!=1) ans.push_back(n);
cout << tmp... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <cmath>
using namespace std;
int main(){
long long n, a=2, sq;
cin >> n;
cout << n << ":";
sq=sqrt(n);
while(n!=1){
if(n%a ==0){
n/=a;
cout << " " << a;
a=2;
}else{
a++;
}
if(a>sq... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
print("{}:".format(n), end='')
x = int(pow(n, 0.5))+1
for i in range(2, x):
while n % i == 0:
print(" {}".format(i), end='')
n //= i
print(' {}'.format(n) if n != 1 else '') | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int t = Integer.parseInt(line);
... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | origin_n=int(input())
n=origin_n
dpair=[]
for i in range(2,int(n**(1/2))+1):
k=0
while True:
if n//i == n/i:
k+=1
n/=i
else:
break
if k!=0:
dpair.append([i,k])
if n!=1:
dpair.append([int(n),1])
print(f"{origin_n}:",end="")
for i in dpair:
for k in range(i[1]):
print(f" {i[0]}",end="")
print()
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
long long i,n;
cin >> n;
cout << n << ":" ;
i=2;
while(i*i<=n){
if(n%i==0){
n/=i;
cout << " " << i;
}else{
i++;
}
}
cout << " " << n;
cout << endl;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
cin >> n;
cout << n << ": ";
m=n;
for (int i=2; i*i<=m; i++) {
if (m%i == 0) {
cout << i << " ";
m/=i;
i-=1;
}
}
cout << m << endl;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
def prime_factors(n):
i = 2
factors = []
while i * i <= n:
if n % i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors
if __name__ == '__main__':
print(n,end=":")
print("",*prime_fac... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | num=int(input())
print(str(num)+': ',end='')
i=2
a=[]
while i*i <= num:
while num % i == 0:
num //= i
a.append(i)
i += 1
if num != 1:
a.append(num)
print (*a)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
a = []
x = n
y = 2
while y*y <= x:
while x%y == 0:
a.append(y)
x //= y
y += 1
if x > 1:
a.append(x)
print('%d:'%n,*a)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
n = int(input())
def prime_factorization(num):
sqrt_num = math.sqrt(num)
prime_numbers = []
for i in range(2, int(sqrt_num) + 1):
# print(num)
while num % i == 0:
# print(num)
num = num / i
prime_numbers.append(i)
if num != 1:
pri... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
N = int(input())
divided = N
prime_factor = []
for i in range(2, int(math.sqrt(N)//1)+1):
while divided%i == 0:
prime_factor.append(i)
divided //= i
if divided != 1:
prime_factor.append(divided)
print("{}: ".format(N, *prime_factor), end="")
print(*prime_factor)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
F = {}
tmp = n
i = 2
while i**2 <= tmp:
cnt = 0
while tmp % i == 0:
cnt += 1
tmp //= i
if cnt > 0:
F[i] = cnt
i += 1
if tmp != 1 or F == {}:
F[tmp] = 1
G = []
for p in F:
for i in range(F[p]):
G.append(str(p))
G = ' '.join(G)
print(f'{n}: {G}')
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n=int(input())
m=int(n**(1/2))
F=[]
n1=n
k=2
#rangeで処理していたのを変更:for i in range(m):
while k<=m:
if n%k==0:
F.append(k)
n//=k
#print(n)
while n%k==0:
F.append(k)
n//=k
k+=1
if n>m:
F.append(n)
print(n1,end=": ")
print(*F)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n;
m = n;
cout << n << ':';
for (int i = 2; i * i < m; i++) {
while (n % i == 0) {
cout << ' ' << i;
n /= i;
}
}
if (n > 1) {
cout << ' ' << n;
}
cout << endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n=int(input())
nc=n
out=[]
while n%2==0:
out.append(2)
n//=2
for i in range(3,int(n**0.5)+1,2):
if n==1 : break
while n%i==0:
out.append(i)
n//=i
if n!=1 : out.append(n)
print("{}: {}".format(nc," ".join(map(str,out))))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
n_hype = n
ans = []
for i in range(2,int(n**0.5)+2):
while True:
if n_hype%i==0:
ans.append(i)
n_hype /=i
else:
break
if n_hype!=1:
ans.append(int(n_hype))
print('{}:'.format(n),end = '')
for a in ans:
print('',a,end = '')
print()
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | def main():
N = int(input())
ans = [str(N) + ':']
while not N % 2:
N //= 2
ans.append(2)
i = 3
while i ** 2 <= N:
while not N % i:
N //= i
ans.append(i)
i += 2
if N != 1: ans.append(N)
print(' '.... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
vector<int> f;
void solve(int n){
cout<<n<<":";
int i=0;
for(i=2;i*i<=n;i++)
while(n%i==0)f.push_back(i),n/=i;
if(n!=1)f.push_back(n);
for(int i=0;i<f.size();i++){
cout<<" "<<f[i];
}cout<<endl;
}
int main(){
int n;cin>>n;
solve(n);
return 0;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
factors = []
p = 2
m = n
while p * p <= m:
if m % p == 0:
m //= p
factors.append(p)
#m //= p
else:
p += 1
if m != 1:
factors.append(m)
print(f'{n}:', *factors)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
cout<<n<<":";
for(int i=2;i*i<=n;i++){
while(n%i==0){
cout<<" "<<i;
n/=i;
}
}
if(n!=1)cout<<" "<<n;
cout<<endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<stdio.h>
#include<string.h>
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;
int main(){
std::istream & c_in = cin;
int n;
c_in >> n;
cout << n << ":";
int primes=0;
int i = 2;
while (n != 1)
{
if ((n % i) == 0) {
n /= i;
cout << " " << i;
continue;
}
i += 1 +... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
scan.close();
System.out.print(n +":");
for(int i = 2; i * i <= n; i++) {
if(n % i == 0) {
while(n ... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
n1 = n
p = 2
primes = []
while n1 != 1:
if n1%p == 0:
n1 /= p
primes.append(p)
elif n1 == 999993031:
primes = [999993031]
break
else:
p += 1
print((str(n)+":"),*primes,sep = " ")
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
print('{}:'.format(n), end='')
i = 2
while i <= int(n ** .5):
if n % i == 0:
n //= i
print('', i, end='')
else:
i += 1
if n != 1:
print('', n)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <cstdio>
using namespace std;
int main(void){
int n,f;
scanf("%d", &n);
printf("%d:", n);
while (n%2==0) {
printf(" 2");
n/=2;
}
f = 3;
while (f*f<=n){
while (n%f==0){
printf(" %d", f);
n /= f;
}
f+=2;
}
if (n>=2) printf(" %d", n);
put... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
void solve(int n){
for (int i = 2; i*i <= n; i++){
if (n % i == 0) {
cout << i << " "; solve(n / i); return;
}
}
cout<<n<<endl;
}
int main() {
int n; cin >> n; cout << n << ": "; solve(n);
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 |
def is_prime(N):
i = 0
if N <= 1:
return False, i
i = 2
while i*i <= N:
if N%i == 0:
return True, i
i += 1
return True, N
N = int(input())
print(str(N)+': ', end='')
ans = []
while True:
F, i = is_prime(N)
if F:
ans.append(i)
N //= i
... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {
/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args) throws NumberFormatExcept... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n;
signed main() {
cin >> n;
cout << n << ":";
for (int i = 2; i <= sqrt(n); i++) {
while (n % i == 0) {
n /= i;
cout << " " << i;
}
}
if (n != 1)cout << " " << n;
cout << endl;
return 0;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
/**
* Elementary Number Theory - Prime Factorize
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new In... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n;
cin>>n;
cout<<n<<':';
for(int64_t i=2;i*i<=n;i++){
if(n%i==0){
while(n%i==0){
cout<<' '<<i;
n/=i;
}
}
}
if(n!=1)
cout<<' '<<n<<endl;
els... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
using namespace std;
int main()
{
int n, i = 2;
cin >> n;
cout << n << ':';
while (i * i <= n)
{
if (n % i != 0)
{
i++;
continue;
}
cout << ' ' << i;
n /= i;
}
cout << ' ' <<n << endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
N = n
print(n, end = ":")
i = 2
ans_list = []
while i <= n:
if i * i > N and len(ans_list) == 0:
ans_list.append(N)
break
while n % i == 0:
ans_list.append(i)
n //= i
i += 1
for i in ans_list:
print(" ", end = "")
print(i, end = "")
print()
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import math
n = ii()
def calc(x):
nq = int(math.sqrt(x)+1)
for i in range(2,nq +1):
if x % i == 0:
return x//i, i
return -1,x
x = n
ans = []
while 1:
x,m = calc(x)
... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n = int(input())
ans = '{}:'.format(n)
prime_factors = []
i = 2
while i ** 2 <= n:
ext = 0
while n % i == 0:
ext += 1
n //= i
if ext:
prime_factors.append((i, ext))
i += 1
if n != 1:
prime_factors.append(... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n=int(input())
i=2
ans=str(n)+":"
while n!=0 and i<=n**0.5:
while n%i==0:
n//=i
ans+=" "+str(i)
i+=1
if n==1:
print(ans)
exit()
print(ans+" "+str(n))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | def soinnsuubunnkai(n):
ret = []
for i in range(2, int(n ** (1 / 2)) + 1):
if i > n:break
while n % i == 0:
n //= i
ret.append(i)
if n != 1:
ret.append(n)
return ret
n = int(input())
print(str(n)+": ",end="")
print(*soinnsuubunnkai(n))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
ans = []
x = n
y = 2
while y*y <= x:
while x % y == 0:
ans.append(y)
x //= y
y += 1
if x > 1:
ans.append(x)
print("%d:" % n, *ans)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
cout << n << ":";
for (int i = 2; i * i <= n; ++i) {
while (n % i == 0) {
cout << " " << i;
n /= i;
}
}
if (n != 1) {
cout << " " << n;
}
cout << endl;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
using namespace std;
int main()
{
int n, a = 2;
cin>>n;
cout<<n<<":";
while (a*a <= n && n > 1)
{
if (n % a == 0)
{
cout<<" "<<a;
n = n/a;
}
else a++;
}
if (n > 1) cout<<" "<<n;
cout<<"\n";
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> p;
int i = 2;
int nn = n;
while( nn % i == 0 ) {
p.push_back( i );
nn /= i;
}
for( i = 3; i * i <= nn; i += 2 ) {
while( nn % i == 0 ) {
p.push_back( i );
nn /= i;
}
}
if( nn != 1 ) p.push_back( nn );
cou... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n=int(input())
m=n
ans=[]
for i in range(2,int(n**0.5)+1):
while n % i == 0:
ans.append(i)
n //= i
if n != 1:
ans.append(n)
l=str(m)+":"
print(l," ".join(map(str,ans)))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
StringBuilder sb = new StringBuilder();
sb.append(n).append(":");
ArrayList<Integer> ans = new ArrayList<>();
for (int i = 2; i... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 |
def prime_factor(n):
ass = []
for i in range(2,int(n**0.5)+1):
while n % i==0:
ass.append(i)
n = n//i
if n != 1:
ass.append(n)
return ass
a = int(input())
print(str(a)+': ',end='')
print(*prime_factor(a))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
vector<int> f;
cin >> n;
int a = n;
for (int i = 2; i * i <= n; i++)
while (a % i == 0) {
f.push_back(i);
a /= i;
}
if (a != 1) f.push_back(a);
cout << n << ':';
for (int& e: f)
cout << ' ' << e;
cou... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N;
cin >> N;
cout << N << ":";
if( N <= 1 ) {
cout << " " << N << endl;
return 0;
}
long long int M = sqrtl( N ) + 1;
for( size_t i = 2; i <= M; i++ ) {
while( N%i == 0 ) {
cout << " " << i;
N /= i;
}
}
if( N != 1 ) {
cou... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | // fakuto.cpp
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n;
double s;
cin >> n;
s=sqrt(n);
cout << n << ":";
while(true){
for(int i=2;i<s;i++){
if(n%i==0){
cout << " " << i;
n = n/i;
i=1;
continue;
}
}
if(n==1){break;}
cout << " " << n;
break;
}... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
void pf(int n){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
printf(" %d",i);
pf(n/i);
return;
}
}
printf(" %d\n",n);
}
int main(){
int n;
scanf("%d",&n);
printf("%d:",n);
pf(n);
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = input()
print "%d:"%n,
ans = []
x = 2
while x*x<=n:
while n%x<1:
ans += [str(x)]
n /= x
x += 1
if n-1: ans += [str(n)]
print " ".join(ans) | PYTHON |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | def smallest_factor(integer):
j = 2
while j :
if j ** 2 > integer:
return integer
elif integer % j == 0:
return j
else:
j += 1
n = int(input())
start = str(n)
prime_factors = []
while n >= 2:
prime_factors.append(str(smallest_factor(n)))
n //=... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
def prime_factorization(n):
factor = []
for i in range(2, int(n ** 0.5) + 1):
while (n % i == 0):
factor.append(i)
n //= i
if n != 1:
factor.append(n)
return factor
res = prime_factorization(n)
tmp = [str(n) + ':']
res = tmp + res
print(*res)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
int n,i;
scanf("%d\n",&n);
printf("%d:",n);
for(i=2;i*i<=n;i++){
while(n%i==0){
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | # 68
def factorization(n):
ans = []
_max = int(n ** 0.5 + 1)
while n % 2 == 0:
n //= 2
ans.append(2)
for i in range(3, _max+1, 2):
while n % i == 0:
n //= i
ans.append(i)
if n != 1:
ans.append(n)
return ans
n = int(input())
ans = factori... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <vector>
using namespace std;
// vector
template<typename T>
vector<T> trialDivision(T a) {
vector<T> res;
T i = 2;
while (i * i <= a) {
if (a % i == 0) {
a /= i;
res.push_back(i);
}
else ++i;
}
if (a != 1) res.push_back(a);
return res;
}
int main() {
int n;
cin >> n;
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | # import numpy as np
import math
n = int(input());
orig = n
i = 2
l = []
while i<=math.sqrt(orig):
while n%i== 0:
n /= i
l.append(i)
i += 1
if n != 1:
l.append(int(n))
# if len(l) == 0:
# print("{0}: {1}".format(orig, orig))
# else:
print("{}:".format(orig), *l)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <vector>
using namespace std;
vector<int> factorize(int n) {
vector<int> ps;
for (int i = 2; i * i <= n; ++i) {
while (n % i == 0) {
ps.push_back(i);
n /= i;
}
}
if (n != 1) ps.push_back(n);
return ps;
}
int main()
{
int n;
cin >> n;
vector<int> ps = factorize(n);
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
unsigned long n = 0;
cin >> n;
cout << n << ":";
for (unsigned long i = 2; i <= sqrt(n); i++) {
while (n % i == 0) {
cout << " " << i;
n /= i;
}
}
if(n > 1)
cout << " " << n;
cout << endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.ArrayList;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import java.io.BufferedWrite... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
def soinsu(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 [str(_) for _ in a]
ans = str(n) + ': ' +... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | public class Main{
public static void main(String[] args){
int i,j;
int val = new java.util.Scanner(System.in).nextInt();
int a=2;
System.out.print(val + ":");
while(val>=a*a){
if(val%a==0){
System.out.print(" " + a)... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
import copy
n = int(input())
ncopy = copy.deepcopy(n)
ans = []
while True:
if n % 2 == 1:
break
ans.append(str(2))
n //= 2
i = 3
while True:
if i**2 > n:
break
if n % i == 0:
ans.append(str(i))
n //= i
else:
i += 2
if n != 1:
ans.append(str... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
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
print(f"{n}:", " ".join(list(m... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
a = []
now = n
for i in range(2, n):
while now % i == 0:
now //= i
a.append(i)
if i * i > n:
break
if now != 1:
a.append(now)
print(str(n) + ":", end = "")
for i in a:
print(" " + str(i), end = "")
print()
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
n1 = n
a = 2
x = []
while a*a <= n:
while n % a == 0:
n //= a
x.append(str(a))
a += 1
if n > 1:
x.append(str(n))
print(str(n1) + ": " + " ".join(x))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<math.h>
#include <iostream>
using namespace std;
void Factorization(int v){
int k = 2;
while ( k <= (int)sqrt((double) v)){
if (v % k == 0){
v = v / k;
cout<<" "<<k;
k = 2;
}
else
k++;
}
cout<<" "<<v;
}
int main(){
int n;
cin>>n;
cout<<n<<":";
Factorization(n);
cout<<endl;
return ... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long int ll;
int N;
vector<int>X;
int main()
{
scanf("%d",&N);
int M=N;
for(int i=2;i*i<=M;i++){
while(true){
if(N%i==0){
X.push_back(i);
N/=i;
}
else break;
}
}
if(N!=1)X.push_back(N);
printf("%d:",M);
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
n = int(input())
def fac(m, p):
step = 1 if p ==2 else 2
for i in range(p, int(math.sqrt(m)+1), step):
if m % i == 0:
return i
return m
result = str(n) + ':'
r = n
p = 2
while r > 1:
p = fac(r,p)
r = r//p
result = result + " " + str(p)
print(result) | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
tmp = n
fact = []
for i in range(2,int(-(-n**0.5//1))+1):
while tmp%i == 0:
fact.append(str(i))
tmp //= i
if tmp != 1:
fact.append(str(tmp))
#print(fact)
print(str(n) + ': ' + " ".join(fact))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | N = int(input())
A = []
def is_prime(n):
if n<2:return False
for i in range(2,n):
if i*i>n:break
if n%i==0:return False
return True
n = N
if is_prime(n):
A.append(n)
n=1
for i in range(2,N):
if n%i==0:
while n>1:
A.append(i)
n//=i
if n%... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
long long n; cin >> n;
cout << n << ":";
for(int i = 2; i*i <= n; i++){
while(n % i == 0){
cout << " " << i;
n /= i;
}
}
if(n != 1) cout << " " << n;
cout << endl;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int> v;
int main() {
cin >> N;
int n = N;
cout << N << ":";
for (int i = 2; i*i <N; ++i) {
while (n%i == 0) {
cout <<" " << i;
n /= i;
}
if (n == 1) break;
}
if (n != 1) cout << " " << n;
cout ... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
ans = []
m = n
for p in range(2, n + 1):
if p**2 > n or m == 1:
break
while m % p == 0:
m //= p
ans.append(p)
if m > 1:
ans.append(m)
print('{}: '.format(n), end='')
print(*ans) | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <cmath>
#include <iostream>
using namespace std;
/*int a[1000000001];
int devidenumber(int m) {
if(a[m]!=0) return m/a[m];
else {
int k=2;
while(m%k!=0) ++k;
a[m]=k;
return m/k;
}
}
*/
int n;
int main() {
cin >> n;
cout << n << ":";
while(n !=1) {
int k=2;
while((n%k!=0) && (k <= sqrt(n))) ... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int n = sc.nextInt();
TreeMap<Integer, Integer> map = new TreeMap<>();
int m = n;
for (int i = 2; i <= Math.sqrt(n); i++) {
int coun... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <math.h>
using namespace std;
void Factorization(int v){
int k = 2;
while (v != 1 && k <= sqrt((double) v)){
if (v % k == 0){
v = v / k;
cout<<" "<<k;
k = 2;
}
else
k++;
}
if(v == 1) return;
cout<<... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
cout << n << ':';
for (int i = 2; i * i <= n; i++){
if (n % i == 0){
while (n % i == 0){
cout << ' ' << i;
n /= i;
}
}
}
if (n != 1){
cout << ' ' << n;
}
cout << endl;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | p=lambda x:print(x,end=' ')
n=input()
p(n+':')
n=int(n);s=n**.5
while n%2==0 and n>3:
p(2)
n//=2
d=3
while s>d and n>d:
if n%d==0:
p(d)
n//=d
else:d+=2
print(n)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<math.h>
using namespace std;int main(){int n;cin>>n;cout<<n<<":";for(int i=2;i<sqrt(n)+1;i++){while(1){if(n%i!=0)break;n/=i;cout<<" "<<i;}}if(n!=1)cout<<" "<<n;cout<<endl;return 0;}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
# n<= 10**9なので、高速化する
# 約数列挙でroot N に抑えるか?
def prime_divide(n):
res = []
i = 2
while True:
if n % i == 0:
res.append(i)
n //= i
else:
i += 1
if i > n ** (0.5):
break
if n != 1:
res.append(n)
retu... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n = int(input())
def prime_factorize(n):
fac = []
if n < 2: return fac
while n%2 == 0:
n //= 2
fac.append(2)
for i in range(3,int(n**0.5)+1,2):
while n%i == 0:
n //= i
fac.append(i)
if n != 1: fac.append(n)
return fac
print("{}: {}".format(n," ".... | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
int n;
cin >> n;
cout << n << ":";
while (!(n % 2)) {
cout << " 2";
n /= 2;
}
for (int i = 3; i <= sqrt(n); i += 2) {
while (!(n % i)) {
cout << " " << i;
n /= i;
}
}
if (n != 1) cout... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main{
public static void main(String[] args){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
long n = Long.parseLong(br.readLine());
... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<stdio.h>
int main(){
int a,b;
scanf("%d",&a);
printf("%d:",a);
b=2;
while(a>=b*b){
if(a%b==0){
printf(" %d",b);
a=a/b;
} else {
b++;
}
}
printf(" %d\n",a);
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<cstdio>
int main() {
int n, k;
scanf("%d", &n);
printf("%d:", n);
while (n % 2 == 0) {
printf(" 2");
n /= 2;
}
for (k = 3; n>1; k += 2) {
if (k*k > n) {
printf(" %d", n);
break;
}
while (n%k == 0) {
printf(" %d", k);
n /= k;
}
}
printf("\n");
return 0;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #coding utf-8
import math
import copy
n = int(input())
m = copy.copy(n)
A = []
for i in range(2,int(math.sqrt(m))+2):
if n == 1:
break
if n % i == 0:
while n % i == 0:
A.append(str(i))
n //= i
if n > 1:
A.append(str(n))
print(str(m) + ': ' + ' '.join(A))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
using namespace std;
int main(){
int n;cin >> n;int x=n;
cout << n << ":";
for(int i=2;i*i<=x;i++){
while(n%i==0) {
cout << " " << i;
n/=i;
}
}
if(n!=1)
cout << " " << n;
cout << endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
long n = Long.parseLong(br.readLine());
printFactor(n);
} ca... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
n = int(input())
k = n
l = []
for i in range(2, int(math.sqrt(n))+1):
while k % i ==0:
l.append(i)
k = k // i
if k == 1:
break
if k != 1:
l.append(k)
print("{}: ".format(n),end="")
print(*l)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n=int(input())
x=n
ans=[]
for i in range(2,int(x**0.5)+1):
if n%i==0:
while n%i==0:
ans.append(i)
n//=i
if ans==[]:
ans.append(x)
elif n!=1:
ans.append(n)
print(str(x)+": "+" ".join(map(str,ans)))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
i = int(input())
print(i,end="")
print(":",end="")
while i>1:
d=2
while i%d != 0:
if d>=math.sqrt(i):
d=i
break
d += 1
print(" ",end="")
print(d, end="")
i = i // d
print()
| PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.