Posted on 2009-03-13 17:25
Hero 阅读(88)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1159 Accepted 0 76 405 C++
2 //很水很暴力
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7
8 int inn ;
9 double inq ;
10
11 int main()
12 {
13 while( scanf( "%d", &inn) != EOF )
14 {
15 scanf( "%lf", &inq ) ;
16 double out = 1 ; double q = inq ;
17 for( int i=1; i<=inn; i++ )
18 {
19 out += q ;
20 q = q * inq ;
21 //printf( "out = %lf\n", out ) ;
22 //printf( "q = %lf\n", q ) ;
23 }
24
25 printf( "%0.3lf\n", out ) ;
26 }
27 return 0 ;
28 }