某OJ无人AC的题
  • 板块灌水区
  • 楼主syex_WXy
  • 当前回复13
  • 已保存回复13
  • 发布时间2025/1/20 15:32
  • 上次更新2025/1/20 18:13:41
查看原帖
某OJ无人AC的题
1399367
syex_WXy楼主2025/1/20 15:32

爬塔

题目描述

​ 小明在玩爬塔游戏,他从第一层开始。

​ 他的目标是爬到第n层的第r个房间,他目前位于第1第l个房间,接下来他要一路披荆斩棘到达目标房间。

​ 每个房间都会有收益,对于第i层第j个房间收益为i。

​ 小明从起点出发,先扫荡完第一层第l个房间到第r个房间,再从第一层第r个房间通过神秘的阶梯到达第二楼第l个房间,再扫荡完第二层第l∼r个房间,依次类推,直到到达第n层第r房间。

​ 小明想知道自己的收益。

输入格式

​ 第一行三个整数n,l,r。

输出格式

​ 一行一个整数,表示答案

样例数据

输入1

2 3 4

输出1

6

样例解释

第一层收益为1,1;第二层收益为2,2.

一共收益为1+1+2+2=6

数据规模与约定

对于30%的数据,1≤n,l,r≤100。

对于60%的数据,1≤n,l,r≤10^3。

对于80%的数据,n≤10^6。

对于100%的数据,1≤n≤10^9,1≤l≤r≤10^6。

后台评测数据:

Test #1:

input: 2 96 100

output:
15

Test #2:

input: 72 13 38

output: 68328

Test #3:

input: 57 73 85

output: 21489

Test #4:

input: 449 331 564

output: 23639850

Test #5:

input: 199 74 540

output: 9293300

Test #6:

input: 913 453 540

output: 36717208

Test #7:

input: 780104 8507 877461

output: 264406944266544300

Test #8:

input: 617537 3781 385237

output: 72734802484945521

Test #9:

input: 539897 2054 171112

output: 24639445672416927

Test #10:

input: 707423041 11802 582357

output: 142766621864837896550716

最后一个测试点没人对,那就附上能对九个的代码,请大佬帮个忙把第十个也AC吧。。。

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,l,r;
	scanf("%lld%lld%lld",&n,&l,&r);
	ll m=r-l+1;
	ll ans=(n+1)*n/2*m;
	printf("%lld\n",ans);
	return 0;
} 
2025/1/20 15:32
加载中...