AP系列之和

大浩姑娘_2550

大浩姑娘_2550

2024-03-13

806人浏览

转载

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...找到系列的总和。

<strong>Input :</strong> a = 1
        d = 2
        n = 4
<strong>Output :</strong> 16
+ 3 + 5 + 7 = 16

<strong>Input :</strong> a = 2.5
        d = 1.5
        n = 20
<strong>Output :</strong> 335

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 1

约束:
1 1
Example:

Input:
1 2 4
2.5 1.5 20

<strong>Output:</strong>
16.00
335.00

其实,就是一个等差数列的求和问题,不过需要注意的是输出是两位小数。

下面是我的代码实现:

#include 
#include 

int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n float a scanf printf return><p>然后竟然出现了错误?一起来看一下:</p><div class="aritcle_card flexRow artxards">
											<div class="artcardd flexRow">
												<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill10918" title="Linux Security Scanner"><img
														src="https://img.php.cn/upload/skill/001/246/273/6adaf20cf0281539.jpg" alt="Linux Security Scanner" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
												<div class="aritcle_card_info flexColumn">
													<a rel="nofollow" href="/xiazai/skill10918" title="Linux Security Scanner" class="overflowclass">Linux Security Scanner</a>
													<p class="overflowclass">Linux 安全审计工具,检查 SSH 配置、开放/监听端口、防火墙规则(ufw/iptables/nftables)、失败登录尝试、sudoers 权限...</p>
												</div>
												<a rel="nofollow" href="/xiazai/skill10918" title="Linux Security Scanner" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
												</a>
											</div>
										</div>
<p><img src="https://img.php.cn/upload/article/000/000/164/171029420168387.png?x-oss-process=image/resize,p_40" alt="AP系列之和">我试了几次的double类型,也都是这个错误。不是很理解怎么做?这个题目的考察点在哪里哦?</p></n>

相关文章

PHP速学视频免费教程(入门到精通)
PHP速学视频免费教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
python中print函数的用法
python中print函数的用法

python中print函数的语法是“print(value1, value2, ..., sep=' ', end='\n', file=sys.stdout, flush=False)”。本专题为大家提供print相关的文章、下载、课程内容,供大家免费下载体验。

2023.09.27

3180

5

python print用法与作用
python print用法与作用

本专题整合了python print的用法、作用、函数功能相关内容,阅读专题下面的文章了解更多详细教程。

2026.02.03

269

24

c++怎么把double转成int
c++怎么把double转成int

本专题整合了 c++ double相关教程,阅读专题下面的文章了解更多详细内容。

2025.08.29

4328

10

C++中int、float和double的区别
C++中int、float和double的区别

本专题整合了c++中int和double的区别,阅读专题下面的文章了解更多详细内容。

2025.10.23

824

4

点击input框没有光标怎么办
点击input框没有光标怎么办

点击input框没有光标的解决办法:1、确认输入框焦点;2、清除浏览器缓存;3、更新浏览器;4、使用JavaScript;5、检查硬件设备;6、检查输入框属性;7、调试JavaScript代码;8、检查页面其他元素;9、考虑浏览器兼容性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

2023.11.24

894

4

Vite 项目如何打包和部署
Vite 项目如何打包和部署

Vite项目打包部署专题汇集生产构建、产物预览、输出目录、资源路径、Nginx与GitHub Pages部署及常见白屏和路由404问题的已审核文章,帮助读者完成上线流程。

2026.10.28

80

16

Vite 如何搭配 Vue.js
Vite 如何搭配 Vue.js

Vite搭配Vue.js专题汇集创建Vue 3项目、配置开发环境、路径别名、Vue插件、代理、多环境构建与调试的已审核文章,帮助读者完成从初始化到日常开发的配置。

2026.10.28

60

15

Vite 项目目录怎么看
Vite 项目目录怎么看

Vite项目目录专题汇集入口文件、src源码、public静态资源、路径别名、项目根目录和构建输出目录相关的已审核文章,帮助读者理解各文件夹的用途与引用方式。

2026.10.28

220

10

Gradle插件开发入门教程
Gradle插件开发入门教程

本专题介绍Gradle插件开发的基本流程,涵盖插件类编写、自定义任务注册、扩展参数设计和插件应用方法,帮助你理解插件如何组织构建逻辑,减少多个项目之间的重复配置。

2026.10.22

140

11

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Python uv官方安装与入门文档
Python uv官方安装与入门文档

共0课时 | 0人学习

Buffalo框架快速入门指南
Buffalo框架快速入门指南

共0课时 | 0人学习

Valgrind支持平台说明
Valgrind支持平台说明

共0课时 | 0人学习