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
import math n = input() prime = [] #find prime numbers in 1-sqrt(n) m = int(math.sqrt(n)) for i in range(m+1): prime.append(True) prime[0] = False prime[1] = False for i in range(2, int(math.sqrt(m))): if not prime[i]: continue else: for j in range(i+1, int(math.sqrt(m))): if j...
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 math N = int(input()) n = N a = [] for i in (n for _ in ([2], range(3, int(math.sqrt(n))+1, 2)) for n in _ ): while n%i==0: a.append(str(i)) n //= i if n>1: a.append(str(n)) print(str(N)+": "+(" ".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
n = int(input()) def factorize(n: int) -> list: a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a print(f'{n}:', *(fact...
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include <bits/stdc++.h> #define pb push_back using namespace std; int n; vector<int>v; int main() { ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n; int t=n, i=2; while (i<=sqrt(t)) { if (t%i==0) v.pb(i), t/=i; else ++i; } cout<<n<<":"; for (int p:v) cout<<' '<...
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
n = int(input()) print(str(n)+":",end = " ") while n >= 4 and n % 2 == 0: print("2",end = " ") n //= 2 d = 3 q = n//d while q >= d: if(n % d == 0): print(str(d),end = " ") n = q else: d += 2 q = n // d 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()) x =[] y = 2 z = n while y*y <= z: while z % y == 0: x.append(y) z = z//y y += 1 if z > 1: x.append(z) print("%d:" % n,*x)
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include<iostream> #include<math.h> using namespace std; int main(){ int x; cin >>x; cout <<x<<":"; for(int i=2;i<=sqrt(x);i++){ while(x%i==0){ cout <<" "<<i; x/=i; } } if(x!=1) cout<<" "<<x; 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 <bits/stdc++.h> #define REP(i,n) for(int i = 0;i < (n);i++) using namespace std; int n; int main(){ cin >> n; int def_half_n = n/2+2; int def_n = n; cout << n << ":"; while(n%2==0){ cout << " " << 2; n /= 2; } if(n==1){cout << endl; return 0;} for(int i = 3;i*i<=n;i+=2){ while(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
import java.util.*; class Main{ public static int bunkai(int n){ int r = 0; int x = (int)Math.sqrt(n); for(int i=2; i<=x; i++){ if(n % i == 0){ r = i; break; } } if(r == 0){ r = n; } return r; } public static void main(String args[]){ ...
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()) nc = n ans = list() i = 2 while(i <= math.sqrt(n)): if(n % i == 0): ans.append(str(i)) n = n // i else: i += 1 if(n != 1): ans.append(str(n)) print(str(nc) + ': ' + ' '.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
def prime_factorize(n): x=2 lim=int(n**0.5) factors=[] while n!=1 and x<=lim: if n%x==0: n//=x factors.append(x) else: x+=1 if n!=1: factors.append(n) return factors n=int(input()) print(n,': ',sep='',end='') print(*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
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) #define repd(i,a,b) for (int i = (a); i < (b); i++) typedef long long ll; int main(void) { ll n; cin >> n; cout << n << ":"; for(ll 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
n=int(input()) def prime_decomposition(n): i = 2 table = [] while i * i <= n: while n % i == 0: n //= i table.append(i) i += 1 if n > 1: table.append(n) return table print("{0:d}".format(n)+": "+" ".join(map(str,prime_decomposition(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()) P=list() N=n y=2 while y*y<=N: while N%y==0: P.append(y) N//=y y+=1 if N>1: P.append(N) print(n,":",sep="",end="") print("",*P,sep=" ")
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> //by NeighThorn using namespace std; int n,m; signed main(void){ scanf("%d",&n);m=sqrt(n);printf("%d:",n); for(int i=2;i<=m;i++) if(n%i==0){ while(n%i==0) n/=i,printf(" %d",i); } if(n!=1) printf(" %d\n",n); 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 math n = int(input()) x = n print(f'{x}:', end='') cnt = 0 for i in range(2, n+1): if x==1: break if i>math.sqrt(n) and cnt==0: print(f' {n}', end='') break while x%i==0: cnt += 1 x=x//i print(f' {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
import math def primeFactors(n): result = list() while n % 2 == 0: result.append(2) n = n / 2 for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: result.append(i) n = n / i if n > 2: result.append(n) return sorted(result) n = int(input()) print('%d:' % (n), end='') result = primeFactors(...
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 prime = [] for i in range(2, int(n**0.5)+1): while n%i == 0: prime.append(i) n /= i if len(prime) == 0 or n != 1: prime.append(int(n)) print(str(_n) + ":", *prime)
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 = [] cur = 2 while cur * cur <= n: while n % cur == 0: n //= cur fct.append(cur) cur += 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 <iostream> #include <math.h> using namespace std; void Factorization(int v){ int k = 2; while (v != 1 && k <= sqrt((double) v)){ if (v % k == 0){ v = v / k; if(v == 1){ cout<<" "<<k; return; } Factorization(k); k = 2; } else k++; } cout<<" "<<v; } int main(){ int n; cin>...
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
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A&lang=ja def prime_factors(n): # 戻り値はiterable type i = 2 while i * i <= n: if n % i: i += 1 else: n //= i yield i if n > 1: yield n N = int(input()) P = list(prime_factors(N...
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include <iostream> using namespace std; int main(){ int n; cin >> n; cout << n << ":"; for(int i = 2; i*i <= n; i++){ while(!(n%i)){ 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 prime_factorization(n): l = [] i = 2 while i * i <= n: if n % i == 0: n //= i l.append(i) else: i += 1 if n > 1: l.append(n) return l if __name__ == '__main__': n = int(input()) ans = str(n) + ':' ret = prime_factorizatio...
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 ans = [] for i in range(2, int(n**0.5)+1): while n % i == 0: ans.append(i) n //= i if n != 1: ans.append(n) print('{}:'.format(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 <iostream> using namespace std; int main() { long long n; cin >> n; cout << n << ": "; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { 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
n=input() print(n+': ',end='') n=int(n);d=2 while n%d==0 and n>3: print(d,end=' ') n//=d d+=1 m=n//d while m>=d: if(n%d==0): print(d,end=' ') n=m else:d+=2 m=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<bits/stdc++.h> using namespace std; void factorize(int n) { cout<<n<<":"; vector<int> res; for(int i=2;i*i<=n;i++) { while(n%i==0) { res.push_back(i); n/=i; } } if(n!=1) res.push_back(n); for(int i=0;i<res.size();i++) { 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
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; cout << n << ':'; int n2=n; for (int i=2;i*i<=n2;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
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); 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 << " " << 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> using namespace std; int pri(int n) { if (n % 2 == 0){ cout << " " << 2; return n / 2; } for (int i = 3; i <= n / i; i += 2){ if (n % i == 0){ cout << " " << i; return n / i; } } cout << " " << n; return 1; } 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
n = int(input()) factors = [] import math sqrt = math.floor(n ** 0.5) z = n for i in range(2, sqrt + 1): if not z % i: while z % i == 0: factors.append(i) z //= i if z > 1: factors.append(z) print('{}:'.format(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 <iostream> #include <cmath> using namespace std; int main() { int num; cin >> num; cout << num << ":"; int left_num = num; double num_sqrt = sqrt(num); for(int i = 2; i <= num_sqrt; i++) { while(left_num % i == 0) { cout << ' ' << i; left_num /= i; } } if(left_num > 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 <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #define rep(i,n) for(int i = 0;i<n;i++) const long long MOD = 1000000007; int main(){ int n; cin >> n; cout << n << ":"; for(int i = 2; i<=sqrt(n)+1; i++){ if(n % i == 0){ while(n % i == 0){ n /= i; cout << " " << 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
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int x=n; cout<<n<<":"; for(int i=2;i*i<=x;i++){ while(n%i==0){ cout<<" "<<i; n/=i; } } if(n!=1){ cout<<" "<<n; } cout<<endl; return 0; }
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
n = int(input()) m = n result = [] for i in range(2, n+1): while m%i==0: m = m//i result.append(i) if m==1: break if i>n**(1/2) and m==n: result.append(n) break print(str(n)+':', *result)
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
n = int(input()) k = n L = [] for i in range(2,100000): while n%i == 0: L.append(i) n = n//i if n != 1: L.append(n) s = str(k)+':' for i in range(len(L)): s += ' '+str(L[i]) print(s)
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 from heapq import heappush, heappop def sieve(n): is_prime = [True] * (n + 1) prime_list = [] is_prime[0] = is_prime[1] = False prime_list.append(2) for i in range(3, n + 1, 2): if is_prime[i]: prime_list.append(i) for j in range(i * i, n + 1, i): is...
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.Scanner; public class Main { public static void main(String[] args){ Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int i = 2; System.out.print(n+":"); for(int j=2;j<=31622;j++){ if(n%j==0){ break; } if(j==31622){ System.out.println(" "+n); return; ...
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.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); final int MOD = 1000000007; long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); int[] dx = { 1, 0, 0, -1 }; int[] d...
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.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); long vn=sc.nexL(); out.print(vn + ":"); for(int i=2; i<=Math.sqrt(vn); i++){ if(...
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
arr = [] n= int(input()) temp=n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr.append([n, 1]) k=[] for a,s in arr: k+=[a]*s print(str...
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
import math a=int(input()) b=int(math.sqrt(a))+1 print(str(a)+":",end="") for i in range(2,b): while a%i==0: print(" "+str(i),end="") a=a//i if a!=0 and a!=1: print(" "+str(a),end="") print()
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
//By Vlgd #include<bits/stdc++.h> using namespace std; bool prime(int x){ if(x==1||x==0) return false; if(x==2) return true; if(x%2==0) return false; for(int i=3;i*i<=x;i++) if(x%i==0) return false; return true; } void solve(int x){ int i=2; if(prime(x)){printf(" %d\n",x);return;} while(i<=x){ while(prime(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
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; int p = 2; int m = n; do { if (n % p == 0) { cout << " " << p; n /= p; } else { p++; } } while ((n > 1) && (p * p <= m)); 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> #include<bits/stdc++.h> #include<math.h> #include<stdlib.h> #include<stdio.h> #include<string.h> #include<sstream> 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...
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
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); List<Long> unko=new ArrayList<Long>(); int unko2=sc.nextInt(); fra(unko2,unko); int[] Ns=new int[32]; int cnt=0; f...
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.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = Integer.parseInt(scan.next()); scan.close(); int input = n; List<Integer> primeList = 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> #include<cstdio> #include<cmath> using namespace std; void primeFactors(int n) { while (n%2 == 0){ cout << " " << 2; n = n/2; } for (int i = 3; i <= sqrt(n); i = i+2){ while (n%i == 0){ cout << " " << i; n = 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
def prime_factorize(n): l = [] s = '{}:'.format(n) i = 2 while i * i <= n: while n % i == 0: l.append(i) n //= i i += 1 if n != 1: l.append(n) for i in l: s += ' {}'.format(i) return s if __name__ == '__main__': print(prime_factor...
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
def prime_decomposition(n): '''by cocodrips''' i = 2 table = [] while i * i <= n: while n % i == 0: n /= i table.append(i) i += 1 if n > 1: table.append(n) return table n = int(raw_input()) print str(n) + ': '+ ' '.join(map(str,prime_decomposition...
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 <bits/stdc++.h> using namespace std; using i64 = long long; #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) 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(...
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
n=int(input()) def factorize(n): b = 2 fct = [] while b * b <= n: while n % b == 0: n //= b fct.append(b) b = b + 1 if n > 1: fct.append(n) return fct x=factorize(n) L=[str(a) for a in x] L=" ".join(L) print(f'{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
#include <iostream> using namespace std; int main() { int nbr; cin >> nbr; cout << nbr << ":"; for (int i = 2; i*i <= nbr; i++) { while(nbr%i == 0) { cout << " " << i; nbr/=i; } } if (nbr!=1) cout << " " << nbr; 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(){ int N;scanf("%d",&N); int K=N; map<int,int> a; for(int i=2;i<sqrt(N)+3;i++){ while(K%i==0){ a[i]++; K/=i; } } if(K!=1)a[K]++; printf("%d%s",N,":"); for(auto p:a){ for(int i=0;i<p.seco...
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> #define ll long long int using namespace std; int main() { ll n; cin>>n; cout<<n<<":"; while(n%2==0) { n=n/2; cout<<" "<<2; } for(int i=3;i*i<=n;i=i+2) { while(n%i==0) { cout<<" "<<i; n=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
p=lambda x:print(x,end=' ') n=input() p(n+':') n=int(n) s=n**.5 while n%2==0 and n>3:p(2);n//=2 d=3 while s>d and n>d: if n%d>0: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 <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; cout << n << ":"; vector<int> ret; for(int i = 2; i * i <= n; i++) { while(n % i == 0) { n /= i; ret.push_back(i); } } if(n >= 2) ret.push_back(n); for(int i : ret) cout << ' ' << 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
#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){ n /= i; cout<<" "<<i; } } if(n-1) cout<<" "<<n; cout<<endl; return 0; }
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
import java.util.*; import java.io.*; public class Main { void solve (FastScanner in, PrintWriter out, Methods ms) { int n = in.nextInt(); int sq = (int)Math.sqrt(n); if (ms.isPrime(n) == true) { out.println(n+": "+n); return; } out.print(n+":"); for (int i=2; i<=sq; i++) { if (ms.isPri...
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 main() { int n, tmp; cin >> n; cout << (tmp = n) << ":"; for(int i = 2; i * i < n; ++i) { while(!(tmp % i)) { tmp /= i; cout << " " << i; } } if(tmp != 1) cout << " " << tmp; cout << endl; }
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include<iostream> #include<cmath> #include<algorithm> #include<vector> #include<queue> using namespace std; int main(){ long long int n; cin >>n; vector<int> f; long long int m; m=n; for(int i=2;i*i<n;i++){ if(m%i==0){ f.push_back(i); m=m/i; i--; } if(m==1)break; } 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()) 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 b=prime_factorize(n) print(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
#include<iostream> using namespace std; int main(){ int n; cin >> n; int n_copy = n; cout << n << ":"; for (int i = 2; i*i < n_copy; 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
#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){ while (n%i==0){ n/=i; cout<<" "<<i; } } if (n!=1){ cout<<" "<<n; } } int main(){ int n; cin>>n; cout<<n<<":"; prime_fac(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 math import sqrt N = int(input()) i = 2 lis = [] n = N while True: if i>sqrt(n): if n==1: break else: lis.append(str(n)) break if n%i==0: lis.append(str(i)) n //= i else: i += 1 print('{}: '.format(N)+' '.join(lis))
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(){ int n; std::cin >> n; std::cout << n << ":"; int div = 2; int sq = (int)sqrt(n); while(div <= sq){ if(n % div == 0){ std::cout << " " << div; n /= div; sq = (int)sqrt(n); }else{ if(div == 2) div = 3; else div += 2; ...
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.util.ArrayList; import java.util.Collections; import java.util.List; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System....
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 prime_factorization(n): factors = [] for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: while True: factors.append(i) n //= i if n % i != 0: break if n > 1: factors.append(n) return factors n = int(input(...
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; 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; ...
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(b) b = b + 1 if n > 1: fct.append(n) return fct N = int(input()) print('{}:'.format(N),end=' ') print(*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
#include <stdio.h> #include <math.h> int main(void) { int n, i; scanf("%d", &n); printf("%d:", n); for(i = 2; i <= sqrt(n); ) { if(!(n % i)) { n /= i; printf(" %d", i); } else ++i; } 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 <bits/stdc++.h> using namespace std; typedef long long ll; priority_queue<ll, vector<ll>, greater<ll>> ans; void solve(ll n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { ans.push(i); solve(n / i); return; } } ans.push(n); } int main() { ll n; cin >> n; solve(...
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; n > 1; i++) { if (i * i > n) break; 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
from math import sqrt from collections import deque def divide_repeat(p): global n, a, limit while not (n % p): a.append(p) n = n // p limit = sqrt(n) nstr = input() n, p = int(nstr), 3 limit = sqrt(n) a, i = deque(), 3 divide_repeat(2) while p <= limit: divide_repeat(p) p ...
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.InputMi...
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 div(int n); int main(){ int num; cin >> num; cout << num << ":"; while(num!=1){ cout << " " << div(num); num = num / div(num); } cout << endl; } int div(int n){ if(n%2 == 0) return 2; int s=sqrt(n); for(int i=3; i<=s; i+=2){ if(n%i == 0) r...
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include<bits/stdc++.h> using namespace std; int main() { long long int n,pd,i; cin>>n; pd = 2; cout<<n<<":"; while(n%2 == 0){ cout<<" "<<2; n/=2; } for (i=3;i<=sqrt(n);){ if(n%i == 0){ cout<<" "<<i; n/=i; } else i+=2; ...
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
import math n = int(input()) pri = [str(n)+":"] i = 2 while i <= math.sqrt(n): while n % i == 0: pri.append(str(i)) n//=i i+=1 if n != 1: pri.append(str(n)) L=[str(pri) for pri in pri] L=" ".join(L) 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()) print('{}: '.format(n), end='') A = [] i = 2 while n > 1: if n % i == 0: A.append(i) n //= i elif i**2 > n: A.append(n) break 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
#include<iostream> #include<vector> std::vector<int> prime_factorize(int64_t n){ std::vector<int> result; for(int64_t p=2;p*p<=n;++p){ while(n%p==0){ result.push_back(p); n/=p; } } if(n!=1)result.push_back(n); return result; } int main(){ int n; std:...
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()) i = 2 ans = [] n = N while n > 1: if i > N**0.5: ans.append(str(n)) break if n % i == 0: ans.append(str(i)) n = n // i else: i += 1 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> 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 << " "; } } 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
import java.util.Scanner; public class Main { private static Scanner sc; private static int n; public static void main(String[] args){ sc=new Scanner(System.in); n=sc.nextInt(); PrimeFactorize(n); } static void PrimeFactorize(int x){ System.out.print(x+":"); if(!isPrime(x)){ int i=2; while(x!=1){ ...
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
n=int(input()) print(str(n) + ":",end=" ") x=[] a=2 while a*a<=n : while n%a == 0: x.append(a) n=n//a a+=1 if n>1: x.append(n) print(' '.join(str(k) for k in x))
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include<vector> template<class T> std::vector<T> factorize(T N){ std::vector<T> factor; for(unsigned i=2;i*i<=N;++i) while(N%i==0){ factor.push_back(i); N/=i; } if(N>1) factor.push_back(N); return factor; } #include<iostream> int main(){ using namespace std; ...
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
p=lambda x:print(x,end=' ') n=input();p(n+':') m=n=int(n) while n%2==0 and n>3:p(2);n//=2 d=3 while d*d<m 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
import java.util.LinkedList; import java.util.Scanner; class Main { public static void main(String[] args) { LinkedList<Long> list = new LinkedList<>(); long n = new Scanner(System.in).nextLong(), devided = n; for(long i = 2; i <= Math.sqrt(n); i++) { while(devided % 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
n = int(input()) m = n A = "" i = 2 while True: if n%i == 0: A = A + " " + str(i) if i == n: break n = n//i i = 2 else: if i*i >= n: A = A + " " + str(n) break else: i += 1 print("{}:{}".format(m,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 <cmath> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <cstdlib> using namespace std; int main() { int n; cin >> n; int x = n; cout << n << ":"; for(int i = 2; i<= sqrt(x)+1; i++) { while(n%i == 0) { cout << " " << i; n/=i; } } if(n != 1) { cout ...
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#素因数分解した結果をリストで返す def 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 Q = int(input()) alist = factorize...
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; using ll = long long int; int main() { ll n; cin >> n; cout << n << ":"; for (ll nn = n, i = 2; i*i <= nn; 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
#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; }
CPP
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include <iostream> #include <vector> #include <cmath> #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, s, n) for(int i = s; i < n; i++) using namespace std; int main(){ int n; cin >> n; int m = sqrt(n); int num = n; cout << n << ':'; rep2(i, 2, m+1){ while(num%i==0){ num /= 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
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; int i = 2; while(n != 1){ if(n % i == 0){ n /= i; cout << " " << i; } else if (n < i * i) //nが大きい素数である場合がありO(√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
n = int(input()) nf = n ans = [] while n > 1: tmp = n for i in range(2, int(n ** 0.5) + 1): if n % i == 0: ans.append(i) n = n // i break if tmp == n: ans.append(n) n = n // n print(str(nf) + ': ', end='') print(*ans)
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
n = int(input()) num = n A = [] b = 2 while b*b <= n: while n % b == 0: n //= b A.append(b) b += 1 if n > 1: A.append(n) print(str(num)+": "+' '.join(str(f) for f in A))
PYTHON3
p02467 Prime Factorize
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
7
0
#include<iostream> #include<cmath> using namespace std; #define N 31623 //√10^9 int main() { int n; cin >> n; int x = n; //n /= i cout << n << ":"; for (int i = 2; i * i <= x; i++) { while (n % i == 0) { cout << " " << i; n /= i; } } if (n != 1) { //99...
CPP