当前位置:网站首页>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.
边栏推荐
- AssertionError: CUDA unavailable, invalid device 0 requested
- SQL aggregate function handling null [easy to understand]
- 明日考试 最后一天如何备考?二造考点攻略全整理
- CCNP的BGP部分笔记
- Huawei laptop, which grew against the trend in Q1, is leading PC into the era of "smart office"
- IPC mechanism
- Fake wireless speakers in stores? Sony responded: the product has reserved a wired connection interface, which can be used in complex scenarios
- Hands on data analysis data modeling and model evaluation
- Listen to the markdown file and hot update next JS page
- Matlab rounding
猜你喜欢
Tianshu night reading notes -- memory paging mechanism
[leetcode] 11. Container with the most water
百度语音合成语音文件并在网站中展示
Hands on data analysis data modeling and model evaluation
TSDB在民机行业中的应用
海河实验室创新联合体成立 GBASE成为首批创新联合体(信创)成员单位
Q1季度逆势增长的华为笔电,正引领PC进入“智慧办公”时代
带马尔科夫切换的正向随机微分方程数值格式模拟
ICML2022 | 用神经控制微分方程建立反事实结果的连续时间模型
Abnova丨CSV 磁珠中英文说明
随机推荐
JS array object to object
Dataease template market officially released
Fan benefits, JVM manual (including PDF)
pbcms添加循环数字标签
poj3669 Meteor Shower(bfs预处理)
Cloud development technology summit · public welfare programming challenge [hot registration]!
为猪脸识别而进行自己数据集的构建、训练「建议收藏」
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了
年已过半,年终立的Flag实现了几个?
uni-app集成极光推送插件后真机调试提示“当前运行的基座不包含原生插件[JG-JPush]...”问题的解决办法
Texture enhancement
创新药二级市场审饼疲劳:三期临床成功、产品获批也不管用了
IPC mechanism
Unity C# 网络学习(六)——FTP(一)
Redis basic commands and types
放养但没有完全放养(春季每日一题 2)
O (log (min (m, n))
AssertionError: CUDA unavailable, invalid device 0 requested
An Chaoyun: "one cloud with multiple cores" supports the implementation of the national information innovation government cloud