当前位置:网站首页>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.
边栏推荐
- write a number of lines to a new file in vim
- Reverse ordinal number by merge sort
- Excel Chinese character to pinyin "suggestions collection"
- (CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
- PS5连接OPPO K9电视不支持2160P/4K
- 在两个有序数组中找到整体第K小的数可以做到O(log(Min(M,N)))
- AssertionError: CUDA unavailable, invalid device 0 requested
- 创新药二级市场审饼疲劳:三期临床成功、产品获批也不管用了
- Unity C# 网络学习(六)——FTP(二)
- Award winning interface control development kit devaxpress v22.1 officially announced
猜你喜欢

【LeetCode】11、盛最多水的容器

数组中关于sizeof()和strlen

Day 04 - file IO

MeterSphere開源持續測試平臺與阿裏雲雲效DevOps的集成

DataEase模板市场正式发布

Intégration de la plate - forme de test continu open source de metersphere avec Alibaba Cloud Effect devops

Ps5 connected to oppo K9 TV does not support 2160p/4k

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

PS5连接OPPO K9电视不支持2160P/4K

Boutique enterprise class powerbi application pipeline deployment
随机推荐
Preg in PHP_ How to replace variable data
第04天-文件IO
Cake review fatigue in the secondary market of innovative drugs: phase III clinical success and product approval
通达信哪个开户更安全,更好点
(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
CCNP的BGP部分笔记
PMP考试“临门一脚”如何踢得漂亮?
Abnova丨5-甲基胞嘧啶多克隆抗体中英文说明
Baidu voice synthesizes voice files and displays them on the website
Fatigue liée à l'examen du marché secondaire des médicaments innovants: succès clinique de la phase III et approbation du produit
‘distutils‘ has no attribute ‘version
‘distutils‘ has no attribute ‘version
字符串常用方法
Boutique enterprise class powerbi application pipeline deployment
Abnova BSG monoclonal antibody description in Chinese and English
Notes on BGP part of CCNP
脱氧核糖核酸酶I中英文说明书
MeterSphere开源持续测试平台与阿里云云效DevOps的集成
Q1季度逆势增长的华为笔电,正引领PC进入“智慧办公”时代
Chinese and English instructions of Papain