• hdu2086A1 = ?


    http://acm.hdu.edu.cn/showproblem.php?pid=2086

    推出公式为(  n + 1 )  *  a1 + 2 * ( c1 + c1+c2+cq+c2+c3+......+cn) = n * a0 + an 

    #include "stdio.h"
    #include "string.h"
    #include "stdlib.h"
    #include "math.h"
    #include "algorithm"
    #include "iostream"
    
    using namespace std;
    
    int main()
    {
    	int n , i , j ; 
    	double a0 , an ,c[ 3005 ] ,temp ,sum1 ,sum;
    	while( ~scanf( "%d" , &n ) )
    	{
    		scanf( "%lf" ,&a0 ) ;
    		scanf( "%lf", &an ) ;
    		sum1 = sum = 0 ;
    		for(  i = 1 ; i <= n ; i++ )
    		{
    			scanf( "%lf" , &temp) ;
    			sum1 += temp ;
    			sum += sum1 * 2.0 ;
    		/*	scanf( "%lf" ,&c[ i ] ) ;
    		double temp = 0.0 ;
    		for(  i = 1 , j = n ; i <= n ; i++ ,j-- )
    		{
    			temp +=  i * c[ j ] ;
    		}
    		temp = 2.0 * temp ;*/
    		}
    		printf( "%.2lf\n" , 1.0 * ( ( 1.0 * n * a0 + an ) - sum ) /( 1.0 *( n + 1 ) ) ) ;
    	}
    	return 0;
    }
    


  • 相关阅读:
    WEEK
    更新yum源
    Centos6.9安装Mysql5.7.18
    gitlab使用
    gitlab安装
    git客户端
    服务器端配置
    错误问题
    服务器端
    01找出数组中重复的数
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3091669.html
Copyright © 2020-2023  润新知