多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 互聯網 > School Personal Contest #1 (Codeforces Beta Round #38)---A. Army

School Personal Contest #1 (Codeforces Beta Round #38)---A. Army

來源:程序員人生   發布時間:2014-11-09 09:27:11 閱讀次數:3629次

Army
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The Berland Armed Forces System consists of n ranks that are numbered using natural numbers from 1 to n, where 1 is the lowest rank and n is the highest rank.

One needs exactly di years to rise from rank i to rank i?+?1. Reaching a certain rank i having not reached all the previous i?-?1 ranks is impossible.

Vasya has just reached a new rank of a, but he dreams of holding the rank of b. Find for how many more years Vasya should serve in the army until he can finally realize his dream.

Input

The first input line contains an integer n (2?≤?n?≤?100). The second line contains n?-?1 integers di (1?≤?di?≤?100). The third input line contains two integers a and b (1?≤?a?<?b?≤?n). The numbers on the lines are space-separated.

Output

Print the single number which is the number of years that Vasya needs to rise from rank a to rank b.

Sample test(s)
input
3 5 6 1 2
output
5
input
3 5 6 1 3
output
11




解題思路:就是簡單的求區間和。

直接開個和數組,a[i]代表i之前(包括i)的所有數的和。查詢時,直接兩個和減1下便可。





AC代碼:

#include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <time.h> using namespace std; #define INF 0x7fffffff int c[105]; int main() { #ifdef sxk freopen("in.txt","r",stdin); #endif int n, a, b, t; while(scanf("%d",&n)!=EOF) { c[0] = 0; scanf("%d", &c[1]); for(int i=2; i<=n⑴; i++){ scanf("%d", &t); c[i] = c[i⑴] + t; } scanf("%d%d", &a, &b); printf("%d ", c[b⑴] - c[a⑴]); } return 0; }


生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: www.av在线.com | 岛国午夜精品视频在线观看 | 亚洲精品精品一区 | 性欧美videosex18嫩 | 欧美成人性h版 | 日韩欧美亚洲一区精选 | 亚洲欧美日韩精品永久在线 | 亚洲一区2区三区4区5区 | 久久欧美精品欧美久久欧美 | 一区二区在线视频免费观看 | 欧美最猛黑人xxxxwww | 日本久久精品免视看国产成人 | 亚洲18av | 欧美一级高清片欧美国产欧美 | 日本不卡视频在线视频观看 | 日本一区二区三区四区无限 | 5月丁香婷婷 | 欧美xx性 | 2017亚洲天堂| 亚洲欧美日韩第一页 | 国产成人高清一区二区私人 | 免费毛片网 | 激情图片小说区 | 激情欧美成人久久综合小说 | 性欧美videofree中文字幕 | 日韩精品福利 | 久久精品综合一区二区三区 | 国产中文字幕在线观看 | 在线视频 亚洲 | 免费在线看v片 | 天天澡天天碰天天狠伊人五月 | 欧美一级日韩一级亚洲一级 | 成年人视频在线观看免费 | 日韩免费一区二区三区在线 | 欧美国产综合日韩一区二区 | 亚洲自拍偷拍网 | 秋霞一级 | 国产精品66福利在线观看 | 女人18一级毛片免费观看 | 最新中文字幕在线 | 日本一区二区视频 |