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 ...
随机推荐
- JavaScript学习笔记(十三)——生成器(generator)
在学习廖雪峰前辈的JavaScript教程中,遇到了一些需要注意的点,因此作为学习笔记列出来,提醒自己注意! 如果大家有需要,欢迎访问前辈的博客https://www.liaoxuefeng.com/ ...
- [LeetCode] N皇后问题
LeetCode上面关于N皇后有两道题目:51 N-Queens:https://leetcode.com/problems/n-queens/description/ 52 N-Queens II: ...
- 网站图片挂马检测及PHP与python的图片文件恶意代码检测对比
前言 周一一早网管收到来自阿里云的一堆警告,发现我们维护的一个网站下有数十个被挂马的文件.网管直接关了vsftpd,然后把警告导出邮件给我们. 取出部分大致如下: 服务器IP/名称 木马文件路径 更新 ...
- 蓝桥杯 剪邮票 全排列+DFS
剪邮票 如[图1.jpg], 有12张连在一起的12生肖的邮票. 现在你要从中剪下5张来,要求必须是连着的. (仅仅连接一个角不算相连) 比如,[图2.jpg],[图3.jpg]中,粉红色所示部分就是 ...
- nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37
一:开始Nginx的SSL模块 1.1 Nginx如果未开启SSL模块,配置Https时提示错误 1 nginx: [emerg] the "ssl" parameter requ ...
- Laravel 框架安装
Composer 在命令行执行 create-project 来安装 Laravel:就是下面这一句话就OK了!composer create-project laravel/laravel --pr ...
- 使用 dotnet core 和 Azure PaaS服务进行devOps开发(Web API 实例)
作者:陈希章 发表于 2017年12月19日 引子 这一篇文章将用一个完整的实例,给大家介绍如何基于dotnet core(微软.NET的最新版本,支持跨平台,跨设备的应用开发,详情请参考 https ...
- 使用java类破解MyEclipse
今天在网上查资料的时候无意中发现使用java类破解MyEclipse的注册码问题.跟大家分享一下 1.建立JAVA Project,随便命名,只要符合规则就行 2.在刚刚建好的Project右击src ...
- ChromeExtension那些事儿
Chrome Extension是什么呢? 简而言之,就是Chrome扩展,它是基于Chrome浏览器的,我们可以理解它为一个独立运行在Chrome浏览器下的APP,当然核心编程语言就是JavaScr ...
- Secret 的使用场景 - 每天5分钟玩转 Docker 容器技术(109)
我们可以用 secret 管理任何敏感数据.这些敏感数据是容器在运行时需要的,同时我们不又想将这些数据保存到镜像中. secret 可用于管理: 用户名和密码. TLS 证书. SSH 秘钥. 其他小 ...