Sum of AP series——AP系列之和
A series with same common difference is known as arithmetic series. The first term of series is 'a' and common difference is d. The series looks like a, a + d, a + 2d, a + 3d, . . . Find the sum of series.具有相同共同差异的系列被称为算术系列。系列的第一个术语是“ a ”,共同的区别是d。该系列看起来像a + d,a + 2d,a + 3d。。。找到系列的总和。
Input : a =
d =
n =
Output :
+ + + =
Input : a = 2.5
d = 1.5
n =
Output :
Input:
The first line consists of an integer T i.e number of test cases. The first line and only line of each test case consists of three integers a,d,n.
输入:
第一行由整数T即测试用例数组成。每个测试用例的第一行和第一行由三个整数a,d,n组成。
Output:
Print the sum of the series. With two decimal places.
输出:
打印系列的总和。有两位小数。
Constraints:
1<=T<=100
1<=a,d,n<=1000
约束:
1 <= T <= 100
1 <= a,d,n <= 1000
Example:
Input: Output: 16.00 335.00
其实,就是一个等差数列的求和问题,不过需要注意的是输出是两位小数。
下面是我的代码实现:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i,j;
scanf("%d",&n);
;i<n;i++)
{
float a,d,n;
scanf("%f %f %f",&a,&d,&n);
printf()*d/);
}
;
}
然后竟然出现了错误?一起来看一下:

我试了几次的double类型,也都是这个错误。不是很理解怎么做?这个题目的考察点在哪里哦?
Sum of AP series——AP系列之和的更多相关文章
- 深入理解无穷级数和的定义(the sum of the series)
Given an infinite sequence (a1, a2, a3, ...), a series is informally the form of adding all those te ...
- [LeetCode] Sum of Left Leaves 左子叶之和
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...
- LeetCode 560. Subarray Sum Equals K (子数组之和等于K)
Given an array of integers and an integer k, you need to find the total number of continuous subarra ...
- [LeetCode] Largest Sum of Averages 最大的平均数之和
We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the su ...
- [LeetCode] 891. Sum of Subsequence Widths 子序列宽度之和
Given an array of integers A, consider all non-empty subsequences of A. For any sequence S, let the ...
- [LeetCode] Sum of Two Integers 两数之和
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...
- [LeetCode] Maximum Size Subarray Sum Equals k 最大子数组之和为k
Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If t ...
- [LeetCode] Sum of Square Numbers 平方数之和
Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...
- 404. Sum of Left Leaves 左叶子之和
[抄题]: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are ...
随机推荐
- 2964:日历问题-poj
2964:日历问题 总时间限制: 1000ms 内存限制: 65536kB 描述 在我们现在使用的日历中, 闰年被定义为能被4整除的年份,但是能被100整除而不能被400整除的年是例外,它们不是闰 ...
- Java中的回调
又忙了一周,事情差不多解决了,终于有可以继续写我的博客了(各位看官久等了). 这次我们来谈一谈Java里的一个很有意思的东西--回调. 什么叫回调,一本正经的来讲,在计算机程序设计中,回调函数是指通过 ...
- 【LintCode·容易】字符串置换
字符串置换 描述: 给定两个字符串,请设计一个方法来判定其中一个字符串是否为另一个字符串的置换. 置换的意思是,通过改变顺序可以使得两个字符串相等. 样例: "abc" 为 &qu ...
- springboot mybatis redis 二级缓存
前言 什么是mybatis二级缓存? 二级缓存是多个sqlsession共享的,其作用域是mapper的同一个namespace. 即,在不同的sqlsession中,相同的namespace下,相同 ...
- CCF-201312-3-最大的矩形
问题描述 试题编号: 201312-3 试题名称: 最大的矩形 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ ...
- Echarts后台封装option对象
该方法返回的keyword指向了前台负责图表显示的jsp页面 public String keyword() { if(this.dateNum == null || this.dateNum.equ ...
- HTTP协议之URL
1.什么是URL URL的全称是Uniform Resoure Locator,统一资源定位器.URL是浏览器寻找信息时所需的资源位置.当一个人将浏览器指向一个URL,浏览器就会在幕后发送适当的协议报 ...
- 倒水问题 (FillUVa 10603) 隐式图
题意:本题的题意是给你三个杯子,第一二个杯子是空的,第三个杯子装满水,要求是量出一定容量d升的水.若是得不到d升的水,那就让某一个杯子里面的水达到d',使得d'尽量接近d升. 解题思路:本题是给出初始 ...
- 使用oracle DB_LINK的一个注意点
今天使用db_link的时候遇到了个有趣的问题,和大家分享一下; 环境:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bi ...
- 为开源社区尽一份力,翻译RocketMQ官方文档
正如在上一篇文章中写道:"据我所知,现在RocketMQ还没有中文文档.我打算自己试着在github上开一个项目,自行翻译."我这几天抽空翻译了文档的前3个小节,发现翻译真的不是一 ...