Advertisement
fooker

prime factorisation (set output)

Nov 19th, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. set<ll> res;
  5. set<ll> factor(ll n){
  6.     res.insert(n);
  7.     for (ll i=1; i<=n; i++){
  8.         if(n%i==0){
  9.             res.insert(n/i);
  10.         }
  11.     }
  12.     return res;
  13. }
  14. void solve(set<ll>& res){
  15.     for (auto j:res){
  16.         cout<<j<<" ";
  17.     }
  18.     cout<<"\n";
  19.     res.clear();
  20. }
  21. ll countset(set<ll>& res){
  22.     ll z=res.size();
  23.     res.clear();
  24.     return z;
  25. }
  26. int main()
  27. {
  28.     int t;
  29.     cin>>t;
  30.     while(t--){
  31.         ll n;
  32.         cin>>n;
  33.         factor(n);
  34.         cout<<countset(res)<<"\n";
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement