当前位置:网站首页>~4.2 ccf 2021-12-1 序列查询
~4.2 ccf 2021-12-1 序列查询
2022-07-25 09:19:00 【叶萧白】
题目描述

输入

输出

样例输入
样例一
3 10
2 5 8
样例二
9 10
1 2 3 4 5 6 7 8 9
样例输出
样例一
15
样例二
45
子任务

源代码
#include <iostream>
using namespace std;
int main (){
int n,N;
cin>>n>>N;
int *r=new int[N];
r[0]=0;
int temp=0;
int result=0;
int i;
for (i = 1; i <= n; i++) {
cin>>temp;
r[i]=temp;
result+=(r[i]-r[i-1])*(i-1);
}
result+=(N-r[n])*(i-1);
cout<<result<<endl;
return 0;
}
边栏推荐
- Uniapp intercepts route jumps through addinterceptor to control whether the page needs to log in
- Two Sum
- C#语言和SQL Server数据库技术
- log4j2基础配置
- OmniPeek packet capturing tool
- C#语言和SQL Server数据库技术
- Publish Yum private server using nexus3 (offline intranet)
- Reverse Integer
- 保姆级Scanner类使用详解
- Bi business interview with data center and business intelligence (I): preparation for Industry and business research
猜你喜欢

Unable to start debugging on the web server, the web server failed to find the requested resource

Druid 查询超时配置的探究 → DataSource 和 JdbcTemplate 的 queryTimeout 到底谁生效?

ActiveMQ -- dead letter queue

activemq--延迟投递和定时投递

activemq--消息重试机制

redis的五种数据结构原理分析

『每日一问』ReentrantLock加锁解锁

sqli-labs Basic Challenges Less1-10

activemq--死信队列

nacos2.1.0集群搭建
随机推荐
How can technologists start their personal brand? Exclusive teaching of top five KOLs
activemq--可持久化机制之AMQ
jsPDF生成PDF文件,文件不全问题,后台进行文件下载,前台不下载
uni-app - Refused to display ‘xxx‘ in a frame because an ancestor violates the following Content Sec
mysql中的数据结果排名
[De1CTF 2019]SSRF Me
『怎么用』装饰者模式
Leetcode组合总和+剪枝
office文件对应的Content-Type类型
Composition of the interview must ask items
ActiveMQ -- leveldb of persistence mechanism
Go基础1
ActiveMQ -- message retry mechanism
Unable to start debugging on the web server, the web server failed to find the requested resource
Bi business interview with data center and business intelligence (I): preparation for Industry and business research
OmniPeek packet capturing tool
Mongodb exploration phase [easy to understand]
『每日一问』LockSupport怎么实现线程等待、唤醒
什么是单机、集群与分布式?
yarn : 无法加载文件 yarn.ps1,因为在此系统上禁止运行脚本。