1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #define ul unsigned long long using namespace std; vector<int> vb; int gcd(int a,int b) { if(a%b==0) return b; else return gcd(b,a%b); } int main() { int kase=1; int t,increment,lim; ul n,sum=0; cin>>t; while(t--) { cin>>n; vb.clear(); lim = sqrt(n); if(n%2) increment = 2; else increment = 1; for(int i=1;i<=lim;i++) { if(n%i==0) { vb.push_back(i); if(i!=n/i) vb.push_back(n/i); } } int len=vb.size(); sum = 0; for(int i=0;i<len;i++) { for(int j=0;j<len;j++) { sum += gcd(vb[i],vb[j]); } } printf("Case %d: ",kase++); printf("%llu\n",sum); } return 0; } |