当前位置:网站首页>Chrysanthemum chain (winter vacation daily question 39)
Chrysanthemum chain (winter vacation daily question 39)
2022-06-25 01:50:00 【51CTO】
Every day , As part of her walk around the farm , cow Bessie Will pass her favorite grass , One of them is A flower ( Colorful daisies ), The number is
, Line up .
flowers Yes
A flower petal .
As a budding photographer ,Bessie Decided to take some pictures of these flowers .
To be specific , For each pair, meet The flowers of
,Bessie Will give you flowers
To flower
All the flowers between ( Include
and
) Take a picture .
later Bessie When you look at these photos, you notice that there are... In some photos 「 Average 」 The flowers of —— One happens to have A petaled flower , among
Equal to the average number of petals of all flowers in the picture .
Bessie There are several photos with average flowers ?
Input format
The first line of input contains .
The second line contains Space separated integers
.
Output format
Output the number of photos with average flowers .
Data range
sample input :
4
1 1 2 3
sample output :
6
Sample explanation
Each photo containing only one flower will be included in the answer ( In this example, there are Zhang ).
in addition , In this example by
and
The corresponding photos also have average flowers .
using
namespace
std;
typedef
long
long
LL;
const
int
N
=
110;
int
n;
int
q[
N],
s[
N];
// Seeking for i There are several sections that meet the requirements of the topic
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.
边栏推荐
- 为猪脸识别而进行自己数据集的构建、训练「建议收藏」
- Experiment 5 8254 timing / counter application experiment [microcomputer principle] [experiment]
- How to open a stock account? Is it safe to open a mobile account?
- Is GF futures safe? What do I need to open an account?
- PHP 利用getid3 获取mp3、mp4、wav等媒体文件时长等数据
- write a number of lines to a new file in vim
- 谷歌浏览器控制台 f12怎么设置成中文/英文 切换方法,一定要看到最后!!!
- Unity C# 网络学习(六)——FTP(二)
- 海河实验室创新联合体成立 GBASE成为首批创新联合体(信创)成员单位
- Tianshu night reading notes -- disassembly engine xde32
猜你喜欢

創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了
![[leetcode] 11. Container with the most water](/img/40/8bb6506a29f8da797432fee50d3aad.png)
[leetcode] 11. Container with the most water

修身励学篇

Abnova a4gnt polyclonal antibody

Boutique enterprise class powerbi application pipeline deployment

Hands on data analysis data modeling and model evaluation

Tianshu night reading notes -- memory paging mechanism

Google browser console F12 how to set the Chinese / English switching method, we must see the last!!!

百度语音合成语音文件并在网站中展示

(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
随机推荐
IPC机制
弹性蛋白酶中英文说明书
(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
O (log (min (m, n))
DataEase模板市场正式发布
论文翻译 | RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
jwt
修身励学篇
CCNP的BGP部分笔记
"One good programmer is worth five ordinary programmers!"
脱氧核糖核酸酶I中英文说明书
Bi SQL drop & alter
Poj3669 meteor shower (BFS pretreatment)
創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了
Listen to the markdown file and hot update next JS page
Intégration de la plate - forme de test continu open source de metersphere avec Alibaba Cloud Effect devops
Abnova丨A4GNT多克隆抗体中英文说明
Matlab rounding
Redis and jedis
字符串常用方法