当前位置:网站首页>菊花链(寒假每日一题 39)
菊花链(寒假每日一题 39)
2022-06-24 21:38:00 【51CTO】
每天,作为她绕农场行走的一部分,奶牛 Bessie 会经过她最喜爱的草地,其中种有 朵花(五颜六色的雏菊),编号为
,排列成一行。
花 有
朵花瓣。
作为一名崭露头角的摄影家,Bessie 决定给这些花拍些照片。
具体地说,对于每一对满足 的花
,Bessie 会给从花
到花
之间的所有花(包括
和
)拍一张照。
后来 Bessie 查看这些照片时注意到有些照片里存在「平均」的花——一朵恰好有 朵花瓣的花,其中
等于照片中所有花的花瓣数量的平均值。
Bessie 的照片中有几张存在平均的花?
输入格式
输入的第一行包含 。
第二行包含 个空格分隔的整数
。
输出格式
输出存在平均的花的照片数量。
数据范围
输入样例:
4
1 1 2 3
输出样例:
6
样例解释
每张仅包含一朵花的照片均会被计入答案(在这个样例中有 张)。
另外,在这个样例中 为
和
所对应的照片也存在平均的花。
using
namespace
std;
typedef
long
long
LL;
const
int
N
=
110;
int
n;
int
q[
N],
s[
N];
// 求以 i 为起点的区间有几个满足题目要求的
LL
solve(
int
u){
LL
res
=
0;
unordered_set
<
int
>
hash;
for(
int
i
=
u;
i
<=
n;
i
++){
hash.
insert(
q[
i]);
if((
s[
i]
-
s[
u
-
1])
% (
i
-
u
+
1))
continue;
int
avg
= (
s[
i]
-
s[
u
-
1])
/ (
i
-
u
+
1);
if(
hash.
count(
avg))
res
++;
}
return
res;
}
int
main(){
scanf(
"%d",
&
n);
for(
int
i
=
1;
i
<=
n;
i
++){
scanf(
"%d",
&
q[
i]);
s[
i]
=
s[
i
-
1]
+
q[
i];
}
LL
res
=
0;
for(
int
i
=
1;
i
<=
n;
i
++)
res
+=
solve(
i);
printf(
"%d\n",
res);
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
边栏推荐
- Bi-sql like
- php easywechat 和 小程序 实现 长久订阅消息推送
- Tianshu night reading notes -- disassembly engine xde32
- AssertionError: CUDA unavailable, invalid device 0 requested
- [live review] 2022 Tencent cloud future community city operator recruitment conference and SaaS 2.0 new product launch!
- (CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
- How to prepare for the last day of tomorrow's exam? Complete compilation of the introduction to the second building test site
- mpls 笔记 part 1
- IPC mechanism
- 通达信哪个开户更安全,更好点
猜你喜欢

Bi-sql - join

Assembly language (4) function transfer parameters

多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%

粉丝福利,JVM 手册(包含 PDF)
The latest QQ wechat domain name anti red PHP program source code + forced jump to open

动手学数据分析 数据建模和模型评估

ICML2022 | 用神经控制微分方程建立反事实结果的连续时间模型

AutoCAD - two extension modes

pbcms添加循环数字标签

Bi SQL drop & alter
随机推荐
Bi SQL constraints
安超云:“一云多芯”支持国家信创政务云落地
Deoxyribonuclease I instructions in Chinese and English
中金证券靠谱吗?开证券账户安全吗?
TC对象结构和简称
高考之后,必然会出现以下四种情况:
This national day! Tencent cloud wecity will accompany you to travel and light up the city landmark
Audio PCM data calculates sound decibel value to realize simple VAD function
15.线程同步的几种方法
(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
Tencent cloud wecity Hello 2022!
百度语音合成语音文件并在网站中展示
pbcms添加循环数字标签
Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert
全排列II[存在相同元素去重 + 标准回溯]
‘distutils‘ has no attribute ‘version
sql 聚合函数对 null 的处理[通俗易懂]
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
梦想CAD云图与GIS结合演示
Redis persistence