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 ...
随机推荐
- python学习笔记 tuple
1. ()去声明.与list类似,但是其元素不能改变. 2. 需要注意的是1中的不能改变是指()中的元素不能改变,如果其元素是一个list,那么list中的元素是可以改变的,不论是大小还是其他的. 3 ...
- ChatterBot之linux下安装mongodb 02
当前环境 :centos 6.9 mongodb版本 mongodb-linux-x86_64-3.4.4.tgz 使用链接工具:studio-3t-x64.msi.zip 首先我们先来安装mongo ...
- 这些 Drawable 的小技巧,你都了解吗?
一.前言 在 Android 的开发过程中,Drawable 经常会被用到,一般会用 Drawable 为 View 设置一个显示的效果.而在 Android 下,也提供了很多 Drawable 的默 ...
- C#Winform设计的通用标签设计器
技术看点 PropertyGrid的使用 自定义控件的使用 对象序列化成XML GDI+Windows驱动打印 前言 是的,一不小心把公司名称透露了.索性帮公司打一下广告.公司(上海易溯信息科技)是中 ...
- 批量抓取cisco设备配置脚本编写(expect/sed/awk/shell)
应同事需求自行编写了第一个脚本,中间遇到一些坑. 需求,要求抓取设备"show ip interface brief"信息和"show interface des&quo ...
- 微信原始demo
有可能下载最新的demo下载不到这个原版的精简demo了. 这里为大家提供一下.以下代码为原始未改动代码 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 ...
- linux 下配置静态IP
设置静态网络如下[root@bogon network-scripts]# pwd 进入这个路径下 /etc/sysconfig/network-scripts [root@bogon network ...
- 深入理解javascript函数进阶系列第一篇——高阶函数
前面的话 前面的函数系列中介绍了函数的基础用法.从本文开始,将介绍javascript函数进阶系列,本文将详细介绍高阶函数 定义 高阶函数(higher-order function)指操作函数的函数 ...
- Netty4.0.24.Final 版本中 IdleStateHandler 使用时的局限性
使用Netty在客户端和服务端建立通讯通道,一般来说,一个连接可能很久没有访问,由于各种各样的网络问题导致连接已经失效,客户端再次发送请求时会产生连接异常. 基于这个原因,需要在客户端和服务端之间建立 ...
- Spring JDBC(二)SimpleJdbcInsert
上一篇写了关于jdbcTemplate的一些基本使用,这一篇来聊聊SimpleJdbcInsert SimpleJdbcInsert是springjdbc提供的一个简化插入操作的类,下面来看一下常用的 ...