Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define MAXX 10000005
- int t , n;
- bool p[MAXX];
- vector<int> v;
- int main()
- {
- _FastIO;
- memset(p , true , sizeof(p));
- for(int i = 2; i * i < MAXX; i++){
- if(p[i])
- for(int j = i + i; j < MAXX; j += i){
- p[j] = false;
- }
- }
- v.push_back(2);
- for(int i = 3; i < MAXX; i += 2){
- if(p[i]) v.push_back(i);
- }
- cin >> t;
- while(t--){
- cin >> n;
- if(p[n]){
- cout << n << endl;
- continue;
- }
- for(int i = 0; i < v.size(); i++){
- int k = v[i];
- while(!(n % k)){
- cout << k;
- n /= k;
- if(n != 1) cout << " * ";
- }
- if(n == 1) break;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement