SGU 456 Annuity Payment Scheme

水题,推个公式出来,注意精度...一遍A

 1    
 2    /*************************************************************************
 3    	> File Name: code/2015summer/#5/D.cpp
 4    	> Author: 111qqz
 5    	> Email: rkz2013@126.com 
 6    	> Created Time: 2015年07月30日 星期四 13时17分26秒
 7     ************************************************************************/
 8    
 9    #include<iostream>
10    #include<iomanip>
11    #include<cstdio>
12    #include<algorithm>
13    #include<cmath>
14    #include<cstring>
15    #include<string>
16    #include<map>
17    #include<set>
18    #include<queue>
19    #include<vector>
20    #include<stack>
21    #define y0 abc111qqz
22    #define y1 hust111qqz
23    #define yn hez111qqz
24    #define j1 cute111qqz
25    #define tm crazy111qqz
26    #define lr dying111qqz
27    using namespace std;
28    #define REP(i, n) for (int i=0;i<int(n);++i)  
29    typedef long long LL;
30    typedef unsigned long long ULL;
31    const int inf = 0x7fffffff;
32    int s,m,p;
33    double ans;
34    
35    double cal(double x,int n)
36    {
37        double res = 1.0;
38        for ( int i = 1 ; i <= n ; i++ )
39        {
40    	res = res * x;
41        }
42      //  cout<<"res:"<<res<<endl;
43        return res;
44    }
45    int main()
46    {
47        cin>>s>>m>>p;
48        double sum = 0;
49        double per = p*1.0/100+1;
50        for ( int i = 1 ; i <= m;  i++ )
51        {
52    	sum=sum+1.0/cal(per,i);
53    //	cout<<"sum:"<<sum<<endl;
54        }
55     //   cout<<sum<<endl;
56        cout<<fixed<<setprecision(5)<<s*1.0/sum<<endl;
57      
58    	return 0;
59    }
60    
61
62
63