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> #include <cmath> #define int long long using namespace std; signed main() { int n, m; vector<int>v; cin >> n; m = n; for (int i = 2; i <= sqrt(n); i++) { while (m % i == 0) { v.push_back(i); m /= i; } } if (m != 1)v.push_back(m); cout << n << ':'; for (int i : v)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(){ int n; cin>>n; double m=sqrt(n); cout<<n<<':'; while(n%2==0) { cout<<" "<<2; n/=2; } for(int i=3;i<=m;i+=2){ 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> using namespace std; #ifdef ENABLE_DEBUG_OUTPUT #define DEBUG_LOG(s) cout << s << endl; #else #define DEBUG_LOG(s) void(); #endif int main(){ int n; cin >> n; cout << n << ":"; for (auto i = 2; i * i <= n; i++) { while(n % i == 0) { n /= i; 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 math n=int(input()) print(str(n)+":",end=" ") ans=[] i=2 while i<=math.sqrt(n): if n%i==0: ans.append(i) n=n//i else: i+=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
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<n;i++) using namespace std; map<int, int>prime_factor(int 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; auto res = prime_factor(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 = int(N**.5) res = len(str(N)) arr = [] tmp = N for i in range(2,n+1): if tmp % i == 0: while tmp % i == 0: arr.append(i) tmp = int(tmp/i) if tmp != 1: arr.append(tmp) arr = [str(i) for i in arr] print(str(N) + ": " + " ".join(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
#include <iostream> #include <vector> using namespace std; int main() { long long N; cin >> N; cout << N << ":"; for (long long i = 2; i * i <= N; ++i) { while ((N % i) == 0) { cout << " " << i; N /= i; } } if (N != 1) { 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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readL...
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; int main() { int n; cin >> n; cout << n << ':'; for (int i = 2; i <= sqrt(n); i++) { while (n % i == 0) { cout << ' ' << i; n /= i; } } if (n > 1) { cout << ' ' << 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<algorithm> #include<vector> using namespace std; int main() { int n; vector<int>p; cin >> n; int m = n; for (int i = 2; i*i < m; i++){ while (1){ if (n % i == 0){ p.push_back(i); n = n / i; } else break; } } if (n != 1)p.push_back(n); cout << m << ":"; for (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()) x = 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(x) + ":" + " " + " ".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
import math def factorize(n): p = n while True: if p % 2 == 0: p //= 2 yield 2 else: break r = 3 while r < int(math.sqrt(p)+1): if p % r == 0: p //= r yield r else: r += 2 if p != 1: yi...
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 = str(n) + ':' 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, *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 <iostream> #include <cmath> using namespace std; int main(void) { int n; cin >> n; int m = (int)sqrt(n); cout << n << ":"; for(int i = 2;i <= m;i++) { while(n % i == 0) { cout << " " << i; n = 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.util.*; public class Main implements Runnable { private static int MOD = 1_000_000_007; public static void main(String[] args) { // Run with 32MB stack Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024); thread.start(); } @Override public void ...
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()) nn=n a=[] i=2 while i<=math.sqrt(n): if n%i==0: n//=i a.append(str(i)) else: i+=1 if n!=1: a.append(str(n)) print(str(nn)+": "+" ".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
import math n=int(input()) end=math.sqrt(n) q=2 print(n,":",sep="",end="") while(True): if n%q==0: n/=q print(" ",q,sep="",end="") else: q+=1 if q>end or n==1: break if n>1: print(" ",int(n),sep="",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()) n = N limit = int(N ** 0.5) A = [] for i in range(2, limit + 1): while n % i == 0: A.append(i) n //= i if not n == 1: A.append(n) A.sort() print(f'{N}: {" ".join(map(str, 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 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
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <queue> #include <algorithm> #define shosu(x) fixed<<setprecision(x) using namespace std; typedef pair<int,int> P; int n; vector<int> ans; int main(){ cin>>n; cout<<n<<':'; for(int i=2;i*i<=n;i++){ for(;n%i==0;){ ans.push_back(...
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() l = [] l += [str(n)+":"] i = 2 while i * i <= n: while n % i == 0: l += [i] n /= i i += 1 if n > 1: l += [n] print " ".join(map(str,l))
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
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
n = int(input()) def pfact(m): pf = {} for i in range(2,int(m**0.5)+1): while m%i == 0: pf[i] = pf.get(i,0) + 1 m //= i if m>1 : pf[m]=1 return pf ansl = [f"{n}:"] for i, j in pfact(n).items(): for _ in range(j): ansl.append(str(i)) print(" ".join(ansl))
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 import math i=int(input()) #insu bunkai site hairetu de kaesu k=[] num=i j=2 while j*j<=num: if i%j==0: i//=j k.append(j) else: j+=1 if i!=1: k.append(i) print(str(num)+": "+(' '.join(map(str, k))))
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; class Main { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int[] a = new int[1000]; int x = 0; int z = 1; int n = scan.nextInt(); a[0] = n; int na = n; for(int i=2; i<=n/2; i++){ if((n / z) % i == 0){ a[x] = i; x++; z *= 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 factorization(n): L=[] temp=n print(n,end="") print(":",end="") for i in range(2,int(n**(1/2)//1)+1): if temp%i==0: c=0 while temp%i==0: c+=1 temp//=i L.append([i,c]) for j in range(c): 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> #include <algorithm> #include <cstdio> using namespace std; int main(void) { int n;cin>>n; int i=2; cout<<n<<":"; while(n!=1 && i*i<=n){ if(n%i!=0)i++; else{ 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
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 P = p(int(n ** 0.5)) for i in compress(xrange(0,n), P): while n...
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.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throw...
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> #define rep(i, n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using pii = pair<int, int>; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { n /= i; cout << " " << 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 math n = int(input()) m = n l = [] for i in range(2, int(math.sqrt(n))+1): while m % i ==0: l.append(i) m = m // i if m == 1: break if m != 1: l.append(m) 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()) i=2 a=[str(n)+':'] m=n while n>1: if i>m**.5: a.append(n) break if n%i==0: n//=i a.append(i) else:i+=1 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
import java.io.*; import java.util.*; import java.util.Map.*; public class Main { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); Prime prime = new Prime((int)Math.sqrt(n)); Map<Long, Integer> hm = prime.primeFactorize(n); pr.printf("%d:", 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()) print(str(n)+': ',end="") ans=[] 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
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int n,i; cin >> n; cout << n << ":"; for(i=2;n!=1;i++) { if(i>sqrt(n)) { cout << " " << n; n=1; continue; } while(n%i==0) { cout << " " << i; n/=i; } } 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.util.ArrayList; import java.util.Scanner; public class Main { private static int nowPrime = 1; private static ArrayList<Integer> array = new ArrayList<Integer>(); public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); System.out.printf(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 <cmath> #include <iostream> #include <vector> int main() { uint32_t n = 0; std::cin >> n; std::cout << n << ":"; uint32_t remain = n; while (remain % 2 == 0) { std::cout << " " << 2; remain /= 2; } for (size_t i = 3; i * i <= remain; i += 2) { while (remain % i == 0) { std::c...
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()) a = [] b = n for i in range(2,int(math.sqrt(n+1))+10): while b % i == 0: b //= i a.append(i) if b != 0 and b != 1: a.append(b) print(n,end='') print(': ',end='') 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
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; cout<<n<<":"; int a=n; for(int i=2;i*i<=a;i++){ while(n%i==0){ cout<<" "<<i; n/=i; } } if(n>1) c...
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.*; import java.util.*; class Main{ void solve(){ int n = ni(); TreeSet<Integer> set = new TreeSet<>(); boolean[] flag = new boolean[100001]; fill(flag, true); for(int i = 2; i * i <= n; i++){ if(!flag[i]){ continue; ...
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.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.NoSuchElementException; import java.util.Random; import java.util.Scanner; class FastScanner { private final InputStream in = System.in; private final byte[] buffer = 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 <math.h> using namespace std; int main(){ int n, max, p = 2; scanf("%d", &n); max = (int)sqrt(n) + 1; printf("%d:", n); while(p <= max) { if (n % p == 0) { n /= p; printf(" %d", p); continue; } p++; } 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
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int num = n; vector<int> ans; for (int i = 2; i < sqrt(n) + 1; i++) { while (num % i == 0) { num /= i; ans.push_back(i); } } cout << n << ":"; for (int 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
# coding: utf-8 # Your code here! n = int(input()) factors = [] p = 2 m = n while p*p <= m: if m % p == 0: 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() { long long n; cin >> n; cout << n << ":"; long long tmp = n; long long p = 2; while (p * p <= n) { if (tmp % p == 0) { cout << " " << p; tmp /= p; } 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
n = int(input()) p = 2 count = [] print('{}:'.format(n), end = ' ') while p*p <= n: while n%p == 0: n = n//p count.append(p) p += 1 if not n == 1: count.append(n) print(*count)
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> Prime_Factorize(int n){ vector<int> ans; for(int i=2; i*i<=n; i++){ while(n%i == 0){ ans.push_back(i); n /= i; } } if(n!=1) ans.push_back(n); return ans; } int main(){ int n; cin >> n; cout << n << ":"; vector<int>...
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
#NTL_1_A l = [] f = 3 n = int(input()) print(n,end='') print(':',end=' ') while n%2 == 0: l.append(2) n = n//2 while f <= n**(1/2): if n%f == 0: l.append(f) n = n//f else: f += 2 if n != 1: l.append(n) print(' '.join(map(str,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()) n_str = str(n) res = '' for i in range(2, int(n//2) + 1): if res == '' and i > n**0.5//1: res = ' {}'.format(str(n_str)) break while n % i == 0: res += ' {}'.format(str(i)) n //= i if n == 1: break print('{}:{}'.format(n_str, 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
N = int(input()) M = N result = [] i = 2 while i * i <= N: while N % i == 0: N //= i result.append(i) i += 1 if N > 1: result.append(N) print(str(M) + ": " + " ".join(map(str, 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 (true) { int i = 2; while (N >= i * i) { if (N % i == 0) { N /= i; cout << ' ' << i; goto Exit; } i++; } break; Exit:; } 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
#include <iostream> using namespace std; void primeFactorize(int n) { for (int i = 2;i * i <= n; ++i) { while (n % i == 0) { n /= i; cout << ' ' << i; } } if (n != 1) { cout << ' ' << n; } } 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 <bits/stdc++.h> using namespace std; int main(){ long long a,b; cin>>a; cout<<a<<':';b=a; for(int i=2;i*i<=b;i++){ while(a%i==0){ cout<<' '<<i; a/=i; } if(a==1)break; } if(a!=1)cout<<' '<<a; 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
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ll n; cin >> n; printf("%lld:",n); for (ll i = 2; i < 100100; i++) { if(n%i == 0){ printf(" %lld", i); n/=i; i=1; } if(i==100099&&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
#include <iostream> #include <math.h> using namespace std; int main(){ int n; double sq; cin>>n; cout<<n<<":"; sq = sqrt(n); while(1){ if(n%2) break; n /=2; cout<<" 2"; } for(int i=3;i<sq;i+=2){ if(n%i) continue; n /= i; cout<<" "<<i; i -= 2; } if(n != 1)cout<<" "<<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
def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f**2 <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a n = int(input()) prime_factorize(n) print('{}:'.format(n), *prime_factorize(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()) x = n divisor = [] for i in range(2,int(x**(1/2))+1): if n % i == 0: while n % i == 0: n = n // i divisor.append(i) if n != 1: divisor.append(n) print(str(x)+":",*divisor)
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()) num = n fct = [] b = 2 while b * b <= n: while n % b == 0: n //= b fct.append(b) b += 1 if n > 1: fct.append(n) print(str(num) + ": " + ' '.join(str(f) for f in fct))
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<cstdio> #include<functional> #include<algorithm> using namespace std; int main(void) { int n,x,i,a; scanf("%d",&x); printf("%d:",x); a=2; n=x; while(n>1) { if(n%a==0) { printf(" %d",a); n/=a; } else { a++; if(a*a>n){ printf(" %d",n); break; } } } 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
#include <iostream> using namespace std; int n; int main() { cin >> n; cout << n << ":"; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { n /= i; cout << " " << i; } } if (n != 1) cout << " " << n << endl; else 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
def prime_factorize(n): res = [] for i in range(2, int(n**0.5)+1): if n % i != 0:continue ex = 0 while n % i == 0: ex += 1 n = n//i res.append((i, ex)) if n != 1:res.append((n, 1)) return res N = int(input()) res = prime_factorize(N) ans = [] for ...
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_ = n factors = [] while n%2 == 0: factors.append('2') n //= 2 for f in range(3, int(n**0.5) + 1, 2): while n%f == 0: factors.append(str(f)) n //= f if n > 1: factors.append(str(n)) print("{}: {}".format(n_, " ".join(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<iostream> #include<cmath> using namespace std; int main(){ int n; cin >> n; cout << n << ":"; int div=2; int sor = n; while(n!=1){ if(n%div==0){ cout << " " << div; n/=div; } else div++; if(div>(int)(sqrt(sor))){ ...
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; template<typename T, class F> void prime_factors(T n, const F f){ for(T k=2; k*k<=n; ++k){ while(n % k == 0)f(k), n /= k; } if(1 < n)f(n); } int main(){ int n; cin >> n; auto func = [](int x){cout << ' ' << x;}; cout << n << ':'; prime_...
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 p(int x) { int i,j; for(i=2;i<=1000000;i++) { if(x==1){printf("\n"); return;} while(x%i==0) { printf(" %d",i); x=x/i; } } printf(" %d\n",x); } int main() { int x; scanf("%d",&x); pri...
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 PrimeFactorize(n): l = [] for i in range(2, int(n ** 0.5) + 1): if i > n: break while n % i == 0: n //= i l.append(str(i)) if n != 1: l.append(str(n)) return l n = int(input()) print(str(n) + ": " + " ".join(PrimeFactorize(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 <iostream> #include <string.h> #include <algorithm> #include <math.h> using namespace std; int main(){ int n;scanf("%d",&n); printf("%d:",n); for(int i=2;i<=(int)sqrt(n+0.5);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
import math n = int(input()) _n = int(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(int(n))) print(str(_n) + ': ' + " ".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 <algorithm> #include<vector> #include <queue> using namespace std; int main() { long long n; cin >> n; cout << n << ":"; for (int j = 2; j*j <= n; j ++) { while (n % j == 0) { n = n / j; cout << " " << j; } } 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<stdio.h> int main(int argc, char* argv[]){ 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
#include <iostream> #include <cmath> using namespace std; bool isprime(int n){ if(n==1)return false; if(n==2)return true; for(int i=2;i<=sqrt(n)+1;i++){ if(n%i==0)return false; } return true; } int main(void){ int h; cin>>h; // int n=h; cout<<h<<":"; int n=h; for(int i=2;i<=sqrt(h)+1;i++){ if(isprime(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
n=int(input()) n2=str(n) def factorint(N): i=2 fct=[] while i**2<=N: if N%i!=0: i+=1 else: N//=i fct.append(i) if N>1: fct.append(N) return fct print(n2+":"," ".join(map(str,factorint(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<math.h> #include <iostream> using namespace std; void Factorization(int v){ int k = 2; while (v != 1 && 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;...
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.*; import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); System.out.print(n+":"); for(int i=2;i<=Math.sqrt(n);i++){ while(n%i==0){ System.out.print(" "+i); 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
n = int(input()) i = 2 print(str(n)+":",end = "") while True: if n%i == 0: n //= i print("",i,end = "") i = 2 if n == 1: print("") break continue if i > n**0.5: print("",n) break i += 1
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
from math import sqrt n = int(input()) out = [str(n) + ":"] for i in range(2, int(sqrt(n)) + 1): while n % i == 0: n //= i out.append(str(i)) if n != 1 and n not in out: out.append(str(n)) print(" ".join(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
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main{ public static void main(String args[]) throws IOException { Main m = new Main(); m.Run(); } public void Run() { Scanner scan = new Scanner(System.in); 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
#include <iostream> void solve(){ int n; std::cin>>n; std::cout<<n<<":"; int t=n; for(int i=2;i*i<= n; ++i){ while(t%i==0){ std::cout<<" "<<i; t=t/i; } } if(t==n)std::cout<<" "<<n; else if(t!=1)std::cout<<" "<<t; std::cout<<std::endl; } int ...
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, floor from collections import deque def divide_repeat(p): global n, a, limit while not (n % p): a.append(p) n = n // p limit = floor(sqrt(n)) nstr = input() n, p = int(nstr), 3 limit = floor(sqrt(n)) a, i = deque(), 3 divide_repeat(2) while p <= limit: di...
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 << '\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=n1=int(input()) k=int(n**0.5) a=[] while n%2==0: a.append(2) n=n/2 for i in range(3, k, 2): while n%i==0: a.append(i) n=int(n/i) if n==1: break if i*i>n: break if n!=1: a.append(n) print(n1,":",sep="", end="") for i in range(len(a)): print(" ", end="")...
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): fct=[] b,e=2,0 while b*b<=n: while n%b==0: n=n//b e=e+1 if e>0: fct.append((b,e)) b,e=b+1,0 if n>1: fct.append((n,1)) return fct n = int(input()) ans = str(n) + ":" for i,v in factorize(n): ans += (" "+str(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
#include <bits/stdc++.h> #include<algorithm> #define int long long using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF 1000000000000 signed main() { int n; cin>>n; int d=pow(n,0.5)+1; int waru=2; cout<<n<<':'; while(waru<=d){ if(n%waru==0){ cout<<' '<<waru; n/=waru; } el...
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()) num=int(n**0.5) str_n=str(n) l=[] for i in range(2,num+1): while n%i==0: n=n//i l.append(i) if n!=1:l.append(n) print(str_n+':',*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
def prime(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()) r=prime(n) R=map(str,r) u=' '.join(R) 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.InputStream; import java.io.PrintWriter; import java.util.*; import org.omg.CORBA.LongHolder; public class Main { static long MOD=998244353; public static void main(String[] args){ PrintWriter out = new PrintWriter(System.out); InputReader sc=new InputReader(System.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<stdio.h> #include<iostream> #include<algorithm> #include<string> using namespace std; int main(){ long long int N,x=2; cin>>N; cout<<N<<":"; while(1){//cout<<"#"<<x<<endl; if(x*x>N)break; if(N%x==0){ cout<<" "<<x; N=N/x; x=0; } x+=2; if(x!=2&&x%2==0)x--; } 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.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.NoSuchElementException; public class Main { ArrayList<Integer> prime; int N,n; public void solve() { N = nextInt(); boolean find = false; n = N; out.print(N + ":"); for(int ...
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 get_primes(n): lst = [] for x in xrange(2, n+1): is_prime = True for i in xrange(len(lst)): if x % lst[i] == 0: is_prime = False break if x < lst[i]*lst[i]: break if is_prime: lst.append(x) return lst n = int(raw_input()) lst = get_primes(10 ** 5) answer ...
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
from math import sqrt n = int(input()) orig_n = n factor = [] i = 2 while i <= sqrt(n): if n % i == 0: factor.append(i) n //= i else: i += 1 if n != 1: factor.append(n) res = f'{orig_n}: ' + ' '.join(map(str, factor)) 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
n = int(input()) orig_n = n res=[] i = 2 half_n = n // 2 root_n = int(n ** (1/2)) is_prime = True while i <= (root_n): if orig_n % i == 0: is_prime = False break i += 1 if is_prime: res.append(orig_n) while i <= half_n and not(is_prime): if n ==1: break if n % i == 0: 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 = m = int(raw_input()) r = int(math.sqrt(n)) sqrt = int(math.sqrt(r)) p = [1]*r p[0] = 0 for i in range(1,sqrt): if p[i]: p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)] prime=[] for i in range(r): if p[i]: prime.append(i+1) a = [] for i in range(len(prime)): if n % prime[i...
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
#include <iostream> using namespace std; int main(){ long n; cin >> n; long x=n; cout << x << ":";int c=0; long k = 1; int i = 2; while(i*i<=n && k < n) { if (x % i == 0) {cout << " " << i;k*=i;x/=i;c++;} if (x % i != 0) {i++;} } if (k!=n) { cout << " " <<n/k; } cout << endl; retu...
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; inline void prime_fac(int n){ int m=(int)floor(sqrt(n)+0.5); for (int i=2;i<=m;++i){ if (n%i==0){ while (n%i==0) cout <<" "<< i,n/=i ; } } if (n!=1) cout << " " << n ; } int main(){ int x; cin >> x; cout << x << ":"; prime_fac(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
out = [] str_n = input() n = int(str_n) save = n out.append(str_n+':') i = 2 while i*i <= save: if n % i == 0: while n % i == 0: n //= i out.append(i) i += 1 if n > 1: out.append(n) print(" ".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
#include <bits/stdc++.h> using namespace std; int main() { int n;scanf("%d",&n); int N=n;printf("%d:",N); for(int i=2;i<pow(N,0.5)+1;i++) { if(n%i==0){printf(" %d",i);n/=i;i--;} } if(n!=1)printf(" %d",n); printf("\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.util.*; import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); List<Integer> list = new LinkedList<Integer>(); System.out.print(n+":"); for (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
def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() return divisors n = int(input()) n_ = n div = make_divisors(n) ans = [] for d in div[1:]: ...
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.*; import java.util.*; import java.util.Map.*; public class Main { static final int MOD = (int)1e9+7; public static void main(String[] args){ FastScanner sc = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); solve(sc,out); out.flush(); } public static void solve...
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; typedef long long ll; typedef pair<int, int> pii; vector<int>PF(int n) { vector<int>v; for(int i=2;i*i<=n;i++) { if(n%i==0) { while(n%i==0) { n/=i; v.push_back(i); } } } if(n!=1)v.push_back(n); return v; } int main() { int n; cin>>n; vecto...
CPP