【PAT甲级】1104 Sum of Number Segments (20 分)
题意:
输入一个正整数N(<=1e5),接着输入N个小于等于1.0的正数,输出N个数中所有序列的和。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
double a[];
int main(){
//ios::sync_with_stdio(false);
//cin.tie(NULL);
//cout.tie(NULL);
int n;
scanf("%d",&n);
double sum=;
for(int i=;i<=n;++i){
scanf("%lf",&a[i]);
sum+=a[i]*i*(n-i+);
}
printf("%.2lf",sum);
return ;
}
【PAT甲级】1104 Sum of Number Segments (20 分)的更多相关文章
- PAT 甲级 1104. Sum of Number Segments (20) 【数学】
题目链接 https://www.patest.cn/contests/pat-a-practise/1104 思路 最容易想到的一个思路就是 遍历一下所有组合 加一遍 但 时间复杂度 太大 会超时 ...
- PAT甲级——1104 Sum of Number Segments (数学规律、自动转型)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90486252 1104 Sum of Number Segmen ...
- PAT 甲级 1104 sum of Number Segments
1104. Sum of Number Segments (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Pen ...
- PAT甲级——A1104 Sum of Number Segments【20】
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 ...
- PAT (Advanced Level) 1104. Sum of Number Segments (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT甲题题解-1104. Sum of Number Segments (20)-(水题)
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...
- PAT甲级——A1104 Sum of Number Segments
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For exam ...
- PAT Advanced A1104 Sum of Number Segments (20) [数学问题]
题目 Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For e ...
- PAT甲级:1136 A Delayed Palindrome (20分)
PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...
随机推荐
- Spring Boot2 快速入门教程-到上手
Spring Boot2 教程合集 入门 纯 Java 代码搭建 SSM 环境 创建一个 Spring Boot 项目的三种方法 理解 Spring Boot 项目中的 parent 基础配置 配置文 ...
- 野路子码农(5)Python中的装饰器,可能是最通俗的解说
装饰器这个名词一听就充满了高级感,而且很多情况下确实也不常用.但装饰器有装饰器的好处,至少了解这个对装逼还是颇有益处的.网上有很多关于装饰器的解说,但通常都太过“循序渐进”,有的还会讲一些“闭包”之类 ...
- Windows系统对拍程序
Windows系统对拍程序,其中包含c++11用法,请使用c++11标准编译.此对拍程序会在发现错误时显示错误行号以及对应内容,方便比对. 此对拍程序自动使用g++对源代码进行编译.如果出现找不到g+ ...
- vs2010安装
1.网盘上2010安装包可用,先下载到电脑上,然后找到setup文件,安装即可 2.下载插件,基本的文本对齐,tab键补齐等功能 3.测试hello world程序 4.出现的问题 一个文件夹下有多个 ...
- js清空子节点
删除全部子节点 function removeAllChild(){ var div = document.getElementById("div1"); while(div.ha ...
- python中乱码怎么由来与解决方法
前言曾几何时 Python 中文乱码的问题困扰了我很多很多年,每次出现中文乱码都要去网上搜索答案,虽然解决了当时遇到的问题但下次出现乱码的时候又会懵逼,究其原因还是知其然不知其所以然.现在有的小伙伴为 ...
- Python3标准库:textwrap文本自动换行与填充
1. textwrap文本自动换行与填充 textwrap模块提供了一些快捷函数,以及可以完成所有工作的类TextWrapper.如果你只是要对一两个文本字符串进行自动或填充,快捷函数应该就够用了:否 ...
- java&python使用对比的浅析
本人写了一段时间java了,最近半年在写python,遂想将其使用中的共同点和异同点整理出来,方便自己和大家学习. 两者的本质区别,请参考如下别人写的帖子: https://blog.csdn.net ...
- 题解【洛谷P1074】[NOIP2009]靶形数独
题面 题解 一开始写了一个朴素的数独,无任何剪枝优化,得到了\(55\)分的好成绩. 就是这道题加一个计算分数. 代码如下(\(\mathrm{55\ pts}\)): /************** ...
- resize2fs: 报错
报错如下 [root@localhost ~]# resize2fs /dev/mapper/centos-root resize2fs (-Dec-) resize2fs: Bad magic nu ...