- #include <bits/stdc++.h>
- using namespace std;
- vector<int> v[100006];
- double dp[100005];
- int vis[100005];
- void preprocess(){
- for(int i = 1; i <100006; i++){
- for(int j = i; j <100006; j+= i){
- v[j].push_back(i);
- }
- }
- /*
- for(int i = 1; i <=100; i++){
- for(int j = 0; j <v[i].size(); j++){
- cout<<v[i][j]<<" ";
- }
- cout<<endl;
- }
- */
- }
- double DP(int n){
- if(vis[n]) return dp[n];
- if(v[n].size() == 2) return 2.00;
- double sum= 0.00;
- for(int i = 0; i <v[n].size()-1; i++){
- sum+= 1.00+DP(v[n][i]);
- }
- sum+= 1.00;
- sum/= (v[n].size()-1)*1.00;
- vis[n] = 1;
- return dp[n] = sum;
- }
- int main(){
- preprocess();
- dp[1] = 0.00;
- dp[2] = 2.00;
- vis[1] = 1;
- vis[2] = 1;
- int ts;
- cin>>ts;
- for(int k = 1; k <= ts; k++){
- int number;
- cin>>number;
- printf("Case %d: %10lf\n",k,DP(number));
- }
- return 0;
- }
Thursday, 27 July 2017
Lightoj 1038 - Race to 1 Again
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
-
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
No comments:
Post a Comment