UVa 10014 Simple calculations (数学)
来源:互联网 发布:ips显示器知乎 编辑:程序博客网 时间:2024/05/01 14:28
10014 - Simple calculations
Time limit: 3.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=955
The Problem
There is a sequence of n+2 elements a0, a1,…, an+1 (n <= 3000; -1000 <= ai 1000). It is known that ai = (ai–1 + ai+1)/2 – ci for each i=1, 2, ..., n. You are given a0, an+1, c1, ... , cn. Write a program which calculates a1.
The Input
The first line is the number of test cases, followed by a blank line.
For each test case, the first line of an input file contains an integer n. The next two lines consist of numbers a0 and an+1 each having two digits after decimal point, and the next n lines contain numbers ci (also with two digits after decimal point), one number per line.
Each test case will be separated by a single line.
The Output
For each test case, the output file should contain a1 in the same format as a0 and an+1.
Print a blank line between the outputs for two consecutive test cases.
Sample Input
1150.5025.5010.15
Sample Output
27.85
思路:
完整代码:
/*0.009s*/#include<cstdio>int main(void){int t, n;double a0, an, c, sum;scanf("%d", &t);while (t--){ sum = 0.0;scanf("%d%lf%lf", &n, &a0, &an);for (int i = 1; i <= n; i++) {scanf("%lf", &c);sum += (n + 1 - i) * c; }printf("%.2f\n", (an + n * a0 - 2 * sum) / (n + 1));if (t)putchar('\n');}return 0;}
- UVa 10014 Simple calculations (数学)
- uva 10014 Simple calculations(数学推导)
- UVa 10014 - Simple calculations
- uva 10014 - Simple calculations
- uva 10014 Simple calculations
- uva 10014 - Simple calculations
- Uva 10014 - Simple calculations
- UVa 10014 - Simple calculations
- UVA 10014 Simple calculations
- uva 10014 - Simple calculations
- uva 10014 Simple calculations
- UVa 10014 Simple calculations
- UVa 10014 - Simple calculations
- uva 10014 - Simple calculations
- UVA 10014 Simple calculations
- UVA - 10014 Simple calculations
- UVA - 10014 Simple calculations
- uva 10014 Simple calculations
- sqoop的安装
- ArrayList用法整理
- 在VC中加载LIB库文件的三种方法
- static
- VC图像编程
- UVa 10014 Simple calculations (数学)
- 【乱七八糟】atoi、itoa、递归
- 点评团促销 -动态规划 背包
- 关于Snmp++ v3.3.0版的一点看法
- MapReduce:详解Shuffle过程
- vc显示jpg,gif图像简单方法
- 点击按钮改变标签内容(采用lambda函数方式)
- 界面编程:vc美化界面
- 创建一个自己的git学习测试环境!