Untitled
unknown
plain_text
3 years ago
1.1 kB
5
Indexable
/// Bismillah Hir Rahmanir Rahim /// #include<bits/stdc++.h> using namespace std; #include<set> #include<map> #define sp " " #define ll long long #define ull unsigned long long int #define nl endl #define pb push_back #define pf push_front #define vi vector<int> #define vll vector<long long > #define vc vector<char> #define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define time cerr << "Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" sec"<<endl; int divsum(int n) { int sum = 0 ; if (n == 1 ) return sum; for (int i = 2 ; i<=sqrt(n) ; i++) { if (n % i == 0 ) { if (i==(n%i)) sum+=i; else sum+=(i+(n/i)); } } return(sum+1); } int main () { FIO; #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); freopen("error.txt", "w", stderr); #endif int n ; cin >> n ; while (n--) { int k ; cin >> k; cout << divsum(k)<< nl; } time; return 0; }
Editor is loading...