Untitled
user_5668965
c_cpp
a year ago
1.4 kB
8
Indexable
/* AUTHOR : DHRUVIL KAKADIYA */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define float double #define pi (3.141592653589) #define debug(...) 8 #define watch(x) cerr << (#x) << " is " << (x) << endl #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ll power(ll n,ll a){ ll res=1; while(a){ if(a%2) res*=n,a--; else n*=n,a/=2;} return res;} ll modpowe(ll n,ll a,ll p){ ll res=1; while(a){ if(a%2) res= ((res*n)%p) ,a--; else n=((n*n)%p),a/=2;} return res;} ll fastprime(ll a){ if (a != 2 && a % 2 == 0 || a < 2) return 0; for(ll i = 3; i * i <= a; i += 2) if(a % i == 0) return 0; return 1;} ll modInverse(ll a,ll b) {return modpowe(a , b-2, b);} // Code Niche diya he bhai ye sb nahi dekhna tha // Code bhi dekhna hota he bhai niche dekh le // abhi bhi comments read kr raha he tu code dekh void solve() { ll n; cin>>n; vector<ll> v; for(int i=2;i*i<=n;i++){ if(n%i==0){ v.push_back(i); if(n!=i*i) v.push_back(n/i); } } v.push_back(n); sort(v.begin(),v.end()); ll sum=1; for(int i=0;i<v.size();i++){ while(n%v[i]==0) sum+=n,n/=v[i]; } cout<<sum<<endl; } int main() { fast; ll t = 1; // cin >> t; while (t--) solve(); return 0; }
Editor is loading...
Leave a Comment