0
点赞
收藏
分享

微信扫一扫

CCF202112-1 序列查询~~~(极简代码)

圣杰 2023-12-06 阅读 49

问题描述:

CCF202112-1 序列查询~~~(极简代码)_#include

CCF202112-1 序列查询~~~(极简代码)_#include_02

 

CCF202112-1 序列查询~~~(极简代码)_#include_03

解题思路:

#include <iostream>
using namespace std;
int shumu, yushuan, l, r, ans;
int set = 1;
int main()
{
	cin >> shumu >> yushuan;
	cin >> l;
	while (cin >> r)
	{
		ans += (r - l) * set;
		l = r;
		set++;
	}
	cout << (ans + set * (yushuan - r));
}

举报

相关推荐

0 条评论