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 <algorithm> #include <cmath> using namespace std; int n; int factorization(int n){ if(n==1) return 0; cout << n << ": "; for(int i = 2; i <= sqrt(n); i++){ if(n % i == 0){ cout << i << " "; n = n / i; i = 1; } } cout << n << endl; return 0; } void solve(){ 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
#include "bits/stdc++.h" using namespace std; int main() { long long N; cin >> N; int i = 2; cout << N << ':'; while (i <= sqrt(N)) { if (N % i == 0) { cout << ' ' << i; N /= i; } else { ++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 <bits/stdc++.h> using namespace std; int main(){ long n; cin>>n; cout<<n<<':'; long x=n; while(x%2==0){cout<<' '<<2;x/=2;} for(int i=3;i*i<=n;i+=2){ while(x%i==0){ cout<<' '<<i; x/=i; } } if(x!=1)cout<<' '<<x; 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main{ public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); try { ...
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 l=[] def isprime(n): if n==2: return True elif n==1: return False else: for i in range(2,int(n**0.5)+1): if n%i==0: return False return True for i in range(2,int(n**0.5)+1): while n1%i==0: l.append(i) n1=n1//i if isprime(n1): l.append(n1) break...
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(n,': ',sep='',end='') a=2 A=[] while a*a<=n: while n%a==0: n //= a A.append(str(a)) a+=1 if n>1: A.append(str(n)) A=' '.join(A) 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
#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 <bits/stdc++.h> int main() { int n; scanf("%d", &n); printf("%d:", n); for (int i = 2; i * i <= n && n != 1; i++) { while (!(n % i)) { 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; void solve() throws IOException { int n = ni(); ...
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> using namespace std; int judge(long long n) { if(n<2)return 0; else if(n==2)return 1; if(n%2==0)return 0; for(int i=3;i<=n/i;i+=2){ if(n%i==0)return 0; } return 1; } int main() { long long n; cin>>n; cout<<n<<":"; if(judge(n))cout<<" "<<n; else{ for(int i=2;i<=n;i++){...
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 factorize(n): b = 2 fct = [] while b * b <= n: while n % b == 0: n //= b fct.append(str(b)) b = b + 1 if n > 1: fct.append(str(n)) return fct n = int(input()) ans = factorize(n) # str_ans = str(ans) # print(''.join(str_ans)) # print(str_ans) # 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
#include <bits/stdc++.h> using namespace std; int main(){ int n = 0; int limit; scanf("%d",&n); printf("%d:",n); limit = sqrt(n) ; for(int i = 2;i <= n ;){ if(n%i == 0){ printf(" %d",i); n /=i; } else i++; if(i > limit) {printf(" %d",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 = int(input()) N_ = N arr = [] for x in range(2,int(pow(N,0.5) + 1)): while N % x == 0: arr.append(x) N = N // x if N != 1: arr.append(N) print(f"{N_}:", *arr)
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){ new Main().run(); } Scanner sc = new Scanner(System.in); int n; boolean[] p; void run(){ p = new boolean[100000000]; setP(); while(sc.hasNext()){ int n = sc.nextInt(); if(n>=2){ System.out.print(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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception { FastScanner scanner = new FastScanner(System.in); 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
import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); long input = in.nextLong(); Map<Long, Integer> m = primeFactorize(input); System.out.print(input+":")...
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=input() print(n+': ',end='') n=int(n) x = 2 ans = [] while x * x <= n: while n % x == 0: n //= x ans.append(x) x = x + 1 if n > 1: ans.append(n) print(" ".join(list(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 n = int(input()) def factorize_rec(n, factor): for i in range(2, math.floor(math.sqrt(n)) + 1): if n % i == 0: factor.append(i) return factorize_rec(n/i, factor) factor.append(int(n)) return factor def factorize(n): return factorize_rec(n, []) print(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
import java.util.ArrayList; import java.util.List; import java.util.Scanner; //?´??????°????§£?????????????????°?????? public class Main { public static void main(String[] args) { // TODO ????????????????????????????????????????????? Scanner sc = new Scanner(System.in); long n = Long.parseLong(sc.nextLine()); ...
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()) A=[] B=n while n%2==0: n//=2 A.append(2) while n%3==0: n//=3 A.append(3) while n%5==0: n//=5 A.append(5) while n%7==0: n//=7 A.append(7) if n>=10000000: A.append(n) else: for j in range(3,n+1,2): while n%j==0: n//=j A.append(j) prin...
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; 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
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.math.BigInteger; public class Main implements Runnable { static int mod = 1000000007; public static void main(String[] args) { new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();...
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 i = 2 x = [] while i*i <= n: while n % i == 0: n //= i x.append(str(i)) i += 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
public class Main{ public void run(java.io.InputStream in, java.io.PrintStream out){ java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int n, i; n = sc.nextInt(); System.out.print(n + ":"); for(;n != 1;){ for(i = 2;i * i < (n + 1);i++){ if(n % i == 0){ System.ou...
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()) print(f'{n}:', end='') temp = n for i in range(2, int(n**(1/2))+1): if temp % i == 0: while temp % i == 0: print(f' {i}', end='') temp //= i if temp != 1: print(f' {temp}', 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(){ unsigned n; cin >> n; cout << n << ":"; for(unsigned 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
x=n=int(input()) a=[] while n%2==0: a.append(2) n=n//2 m=3 while m*m<=n: if n%m==0: a.append(m) n=n//m else: m+=2 if n!=1: a.append(n) b='' for i in range(len(a)): b=b+' '+str(a[i]) i+=1 print(str(x)+':'+b)
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.InputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { InputStream in = System.in; PrintStream out = System.out; public void _main(String[] args) { Scanner sc = new Scanner(in); int n = sc.nextInt(); sc.close(...
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 <cmath> using namespace std; long long div(long long n1) { for (long long i = 2; i <= sqrt(n1);) { if (n1 % i == 0) { return i; } else { i++; } } return -1; } int main() { long long n; cin >> n; cout << n << ":"; while (1) { if(div(n) == -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
n = int(input()) N = n print(N,":",sep="",end=" ") def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 b = 3 while b * b <= n: if n % b == 0: a.append(b) n //= b else: b += 2 if n != 1: a.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
#73 素因数分解 import math n = int(input()) a = n ans = [] i = 2 while i <= math.sqrt(n): if n % i == 0: n = n //i ans.append(str(i)) else: i += 1 if n != 1: ans.append(str(n)) print(str(a) + ":" + " " + " ".join(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 <iostream> #include <math.h> int main(void) { long int in; long int i = 2; std::cin >> in; std::cout << in << ":"; while (in != 1) { if (i > sqrt(in)) { std::cout << " " << in; break; } else if (in % i != 0) { i += 1; } else { in = in / i; std::cout << " " << i; i = 2; } } st...
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; map< int64_t, int > prime_factor(int64_t n) { map< int64_t, int > ret; for(int64_t i = 2; i * i <= n; i++) { while(n % i == 0) { ret[i]++; n /= i; } } if(n != 1) ret[n] = 1; return ret; } int main() { int N; cin >> N; cout << 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 <map> #include <vector> using namespace std; map<int, int> factorize(int n) { map<int, int> m; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { ++m[i]; n /= i; } } if (n != 1) m[n] = 1; return m; } int main() { int n; cin >> n; cout << 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 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
def prime_factorize(N): # 素因数分解 import math as m a = [] for i in range(2, int(m.sqrt(N)) + 1): while N % i == 0: a.append(i) N //= i if N > 1: a.append(N) return a def resolve(): N = int(input()) a = prime_factorize(N) print(str(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
b = int(input()); n = b; 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) print("{}:".format(b),end = ''); for i in range(0,len(a)): print('',a[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
#include <iostream> using namespace std; int main(void){ int n; cin>>n; cout<<n<<":"; int i=2,m=n; while(m!=1){ if(m%i==0){ m/=i; cout << " " << i; }else{ if(i>=3){i+=2;} else{i++;} } if(i*i>n) { cout << " " << 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
#include <iostream> using namespace std; int main(void){ int num; cin >> num; cout << num << ":"; for(int i = 2; i*i <= num; ++i){ while(num % i == 0){ num /= i; cout << " " << i; } } if(num != 1){ cout << " " << num; } 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
from math import sqrt n = int(input()) def prime_factors(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 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
def p(n): l = [1]*(n+1) l[0] = l[1] = 0 for i in range(2,int(n ** 0.5) + 1): if l[i]: for j in range(2*i, n+1, i): l[j] = 0 return l n = input() l = [] l += [str(n)+":"] from itertools import compress, count P = p(int(n ** 0.5)) for i in compress(count(0), P): whi...
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
# -*- coding: utf-8 -*- # モジュールのインポート import math # 標準入力を取得 n = int(input()) # 求解処理 ans = [] t = n while True: is_prime = True for i in range(2, int(math.sqrt(t)) + 1): if t % i == 0: ans.append(i) t /= i is_prime = False break if is_prime: 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
p=lambda x:print(x,end=' ') n=input();p(n+':') n=int(n);s=n**.5;d=3 while n%2==0 and n>3:p(2);n//=2 while s>d and n>d: if n%d>0:d+=2 else:p(d);n//=d 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<stdio.h> #include<math.h> int main() { int n, i; while(scanf("%d", &n)!=EOF){ printf("%d: ", n); for(i=2; i<=sqrt(n); i++){ if(n%i==0){ printf("%d ", i); n/=i; i=1; } } printf("%d\n", 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 "bits/stdc++.h" using namespace std; int main() { long long N; cin >> N; cout << N << ":"; for (long long i = 2; i * i <= N; i++) { if (N % i == 0) cout << " " << i, N /= i, i--; } if (N != 1) cout << " " << N << 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
import java.util.Scanner; public class Main { public static void main(String[]args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); System.out.print(n+":"); for(int i=2;i<=Math.sqrt(n);i++) { if(n%i==0) { while(n%i==0) { System.out.print(" "+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
#!/usr/bin/env python from collections import deque import itertools as it import sys import math import random sys.setrecursionlimit(1000000) INF = 10 ** 18 n = input() ls = [] n_ = n i = 2 while True: if i * i > n: break while n % i == 0: n /= i ls.append(i) i += 1 if n != 1:...
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 main(): import sys N = int(sys.stdin.readline()) SN = N def calc(N): import math L = [] for i in range(2, int(math.sqrt(N))+2): while N % i==0: L += [i] N = N//i if N !=1: L += [N] print(str(SN) + ': ' + ...
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()) res = [] x = N y = 2 while y*y <= x: while x % y == 0: res.append(y) x//= y y += 1 if x > 1: res.append(x) print("%d:"%N,*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<iostream> using namespace std; typedef long long ll; ll n; void solve(ll n) { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { cout << " " << i; solve(n / i); return; } } cout << " " << n; return; } int main() { cin >> n; cout << n << ":"; solve(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<stdio.h> int main(){ int a,n; scanf("%d",&n); printf("%d:",n); a=2; while(n>=a*a){ if(n%a==0){ printf(" %d",a); n=n/a; } else { a++; } } printf(" %d\n",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
import math n = int(input()) num = [str(n)+":"] i = 2 while i <= math.sqrt(n): while n % i == 0: num.append(str(i)) n//=i i+=1 if n != 1: num.append(str(n)) print(num[0]+" "+str(n) if len(num) == 1 else " ".join(num))
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; 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<iostream> using namespace std; int main(){ int N, n; bool flg = false; cin >> N; cout << N << ":"; n = N; while(n != 1){ flg = false; for(int i=2;i*i<=N;i++){ if(n%i == 0){ n /= i; cout << " " << i; flg = true; break; } } if(!flg){ cout << " " << n; n /= 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=int(input()) ans=[str(n)+":"] i=2 while i*i<=n: while n%i==0: n//=i ans.append(i) i+=1 if n!=1:ans.append(n) 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
i = 2 n = int(input()) n_ = n ans = [] while i*i <= n: while n % i == 0: ans.append(i) n //= i i += 1 if n > 1: ans.append(n) print(str(n_) + ': ' + ' '.join([str(i) for i in 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() { ios::sync_with_stdio(false); cin.tie(NULL); 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...
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> const int LIM=1e6; int a[LIM]; int main() { int n; scanf("%d", &n); printf("%d:", n); for(int i=2; i<=n/i; i++) { while(n%i==0) printf(" %d", i), n/=i; } if(n>1) printf(" %d", n); putchar('\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; void factorize( int n ) { cout << n << ':'; while( n % 2 == 0 ) { cout << ' ' << 2; n /= 2; } int d = 3; int e = sqrt( n ); while( n >= d ) { if( d > e ) { cout << ' ' << n; break; } if( n % d == 0 ) { cout << ' ' << d; n /= d; } else { ...
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.ArrayList; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static ArrayList<Integer> pf = new ArrayList<Integer>(); public static void main(String[] args) { primeFactorize( sc.nextInt() ); } private static void primeFactorize(int nextInt) { int 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
import java.util.Scanner; public class Main { public static void main(String args[]){ try(Scanner sc=new Scanner(System.in)){ int n=sc.nextInt(); System.out.print(n+":"); int x=n; for(int i=2; i*i<=x; i++) { while(n%i==0) { ...
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 def soi(x): y = x a = [] for i in range(2,int(math.sqrt(x))+1): while x%i == 0: a.append(i) x/=i if len(a)==0 or x!=1: a.append(int(x)) a.sort() print(str(y)+':',*a) n = int(input()) soi(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 factorize(n): if n < 4: return [n] res = [] i = 2 while i*i <= n: while n%i == 0: res.append(i) n //= i i += 1 if n != 1: res.append(n) res.sort() return res N = int(input()) f = factorize(N) print(str(N)+": ", 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 <bits/stdc++.h> using namespace std; map<int, int> prime_factor(long long n) { map<int, int> res; for (int i = 2; i * i <= n; ++i) { while (n % i == 0) { ++res[i]; n /= i; } } if (n != 1) res[n] = 1; return res; } int main() { int n; cin >> n; map<int, int> m = prime_fac...
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.*; import static java.lang.System.*; import java.io.*; public class Main { static FastScanner sc = new FastScanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int d = (int)Math.sqrt(n); out.print(n+":"); for (int i=2; i<=d; i++) { while (n%i==0) { n /= 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_fact(n): ret = [] if n == 1: return [1] for d in [2] + list(range(3, int(n ** 0.5) + 1, 2)): while n % d == 0: ret.append(d) n //= d if n != 1: ret.append(n) return ret n = int(input()) print("{}: ".format(n), end = "") print(*prime_fact(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
import math n = int(input()) def factor(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 res = str(n) + ":" p = 2 while n != 1: p = factor(n,p) n = n//p res = res + " " + str(p) 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 <iostream> using namespace std; int main(){ int n; cin>>n; cout<<n<<":"; int j=n; for(int i=2;i*i<=j;i++){ while(n%i==0){ cout<<" "<<i; n=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<iostream> int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n; std::cin >> n; std::cout << n << ":"; for (int i = 2; i * i <= n; i++) { while (n % i == 0){ std::cout << " " << i; n /= i; } if(i != 2) i++; ...
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=input() N=n a=[] x=2 while x*x<=N: while n%x==0: a.append(str(x)) n=n/x if n==1: break x+=1 else: a.append(str(n)) print str(N)+": "+" ".join(a)
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
import java.util.*; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { final Scanner sc = new Scanner(System.in); final long n = sc.nextLong(); final List<Map<Long, Integer>> pfs = primeFactorize(n); System.out.print(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
#include<cstdio> #include<vector> using namespace std; int main(){ int n; vector<int> G; scanf("%d",&n); if(n == 1){ printf("%d: %d\n",n,n); return 0; } int a = n; for(int i = 2; i * i <= n; i++){ while(a%i == 0){ G.push_back(i); a /= i; } } if(a != 1)G.push_back(a); printf("%d:",n); for(int i ...
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()) k=n i=2 l=[] while i**2<=n: while n%i==0: n//=i l.append(i) i+=1 if n>1: l.append(n) print(k,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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long n = scan.nextLong(); run(n); scan.close(); System.exit(0); } private static void run(long n) { System.out.print(n + ":"); double max = Math.sqrt(n); for (long 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
n = int(input()) def function(n): a = [] if n < 2: return a while n%2 ==0: a.append(2) n = n//2 i = 3 while i*i <= n: if n%i ==0: a.append(i) n = n//i else: i += 2 if n > 1: a.append(n) return a print(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
n = int(input()) print(str(n) + ':', end='') while n > 1: for p in range(2, n+1): if n % p == 0: n //= p print(' ' + str(p), end='') break elif p * p > n: print(' ' + str(n), end='') n = 1 break 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 f(n) -> list: if n==1: return [1] ret = [] i = 2 while i*i<=n: while n%i==0: n //= i ret.append(i) i += 1 if n!=1: ret.append(n) return ret n=int(input()) print("{}:".format(n),*f(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
import math n = int(input()) nc = n result = [] i = 2 while i <= math.sqrt(n): if n%i == 0: n //= i result.append(str(i)) else: i += 1 if n != 1: result.append(str(n)) print(str(nc) + ": " + " ".join(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
#include <iostream> using namespace std; int main() { int n;cin>>n; cout<<n<<":"; while(n%2==0) { cout<<" "<<2; n/=2; } for(int i=3;i*i<=n;i+=2) { 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 math def factorize(p): while p % 2 == 0: p //= 2 yield 2 r = 3 while r < int(math.sqrt(p)+1): if p % r == 0: p //= r yield r else: r += 2 if p != 1: yield p n = int(input()) l = factorize(n) print(str(n)+":",*list(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()) print(str(n)+': ',end='') a = [] i = 2 while i*i<=n: while n%i==0: n//= i a.append(i) i+=1 if n!=1: a.append(n) 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x =n; cout << x << ":"; for(int i=2; i*i <=x;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
from collections import defaultdict def factorize(n): result = defaultdict(int) m = n p = 2 while p*p <= m: while n % p == 0: n = n // p result[p] += 1 p += 1 if n > 1: result[n] += 1 return result n = int(input()) factors = factorize(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; typedef long long LL; #define SZ(a) int((a).size()) #define FOR(var,a,b) for(int var=(a);var<(b);var++) #define REP(var,n) FOR(var,0,n) #define INT(n) int n;scanf("%d",&n); int main(){ INT(n); printf("%d:", n); FOR(i, 2, 100000){ if (n < i * i){break;} while...
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 factorization(n): arr=[] tmp=n for i in range(2,int(n**0.5)+1): if(tmp%i==0): cnt=0 while tmp%i==0: cnt+=1 tmp//=i arr.append([i,cnt]) if(tmp!=1): arr.append([tmp,1]) return arr n=int(input()) s=str(n)+':' arr=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
def s(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 n=int(input()) print(f'{n}: ',end='') print(*s(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> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define rep(i,n) for(int i=0;i<n;++i) using namespace std; typedef pair<int,int>P; const int MAX_N = 1000000; void prime_factor(int n) { for(int i=2;i*i<=n;i++){ while(n%i == 0){ printf(" %d",i); n /= i; } } if(...
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 get_min_p(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return i; } } return n; } int main() { int n; cin >> n; cout << n << ":"; while (n > 1) { int p = get_min_p(n); while (n % p...
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()) b = 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) print(f'{b}:',*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 <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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top * * @author silviase */ public class Main { public static void main(String[] ...
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 def factorize(p): l = [] while p % 2 == 0: p //= 2 l.append(2) r = 3 while r < int(math.sqrt(p)+1): if p % r == 0: p //= r l.append(r) else: r += 2 if p != 1: l.append(p) return l n = int(input()) l = fa...
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
a=int(input()) n=a i=2 fc=[] while i*i<=a: while a%i==0: a//=i fc.append(i) i+=1 if a>1: fc.append(a) print(str(n)+": "+" ".join(str(b) for b in fc))
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<cmath> using namespace std; int main(){ int n; cin >> n; cout << n << ":"; for(int i = 2; i <= sqrt(n); i++){ if(n % i == 0){ 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
n = int(input()) m = str(n) + ":" a = True l = n i = 2 while a: if l % i == 0: l /= i m += ' ' + str(i) i -= 1 a = i < l**0.5 i += 1 if l != 1: m += ' ' + str(int(l)) print(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
#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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); long n = Long.parseLong(str); Syste...
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 prime_factorization(n): table = [] for x in range(2, int(n**0.5)+2): while n % x == 0: table.append(x) n //= x if n > 1: table.append(n) return table print("{}:".format(N), *prime_factorization(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; // macro #define rep(i,n) for(i=0;i<n;i++) #define ll long long #define all(v) v.begin(), v.end() // code starts int main() { int n;cin>>n; int m=n; int i; vector<int> ans(0); for(i=2;i*i<=m;i++) { while(n%i==0) { ans.emplace_back(i); n/=i; ...
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 factorize(n): i = 2 m = n factors = [] while i*i <= m: if m%i==0: m //= i factors.append(i) else: i += 1 if m > 1: factors.append(m) return factors n = int(input()) primes = factorize(n) print("{0}: {1}".format(n, " ".join(list(map(str,primes)))))
PYTHON3