#include<bits/stdc++.h>
using namespace std;
vector<int> divisors[100002];
void Divisors(int n)
{
int i,j;
for(i = 1; i<=n; i++)
for(j=i; j<=n; j+=i)
divisors[j].push_back(i);
}
int main()
{
long long T,N,c=1;
Divisors(100010);
cin >> T;
while(T--)
{
cin >> N;
double store[100010];
long long l;
l = divisors[N].size();
for(long long i=0; i<l; i++)
{
if(divisors[N][i] == 1)
store[divisors[N][i]] = 0;
else if(divisors[divisors[N][i]].size() == 2)
store[divisors[N][i]] = 2.000;
else
{
store[divisors[N][i]] = divisors[divisors[N][i]].size();
for(int j=0; j<divisors[divisors[N][i]].size()-1; j++)
store[divisors[N][i]] += store[divisors[divisors[N][i]][j]];
store[divisors[N][i]] /= divisors[divisors[N][i]].size()-1;
}
}
cout << "Case " << c++ << ": ";
printf("%.10lf\n",store[divisors[N][l-1]]);
}
return 0;
}
Thursday, July 30, 2015
1038 - Race to 1 Again
Subscribe to:
Post Comments (Atom)
Triathlon
Triathlon - CodeChef # include < bits/stdc++.h > using namespace std ; # define fi first # define se second # define mp ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , c = 1 ; double r1 , r2 , h , p ; // ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { long long T , S , l , n , c = 1 ; // freopen(&qu...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , n , p , q , c = 1 , i , w , t , arry [ 50 ] ; ...
No comments:
Post a Comment