School Personal Contest #1 (Codeforces Beta Round #38)---A. Army,
Army
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard 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
35 61 2
output
5
input
35 61 3
output
11
解題思路:就是簡單的求區間和。
直接開個和數組,a[i]代表i之前(包括i)的所有數的和。查詢時,直接兩個和減一下即可。
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 0x7fffffffint 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-1; i++){ scanf("%d", &t); c[i] = c[i-1] + t; } scanf("%d%d", &a, &b); printf("%d\n", c[b-1] - c[a-1]); } return 0;}
英語幫忙翻譯
看下,這是我翻譯的,希望對你有協助。
1, organize the school singing contest, the girl's Day activities and personal style competition and other large-scale school activities, responsible for 2 students of school students and school will organize activities only Department of literary program organization. Assist the art troupe and various societies, do well the daily training and activities, is responsible for the management of the student sports venues and related equipment, costumes, planning organizations visited 3 homes for the elderly, visited CDPF, love Kite Festival, mother's day and a series of volunteer activities encourage students to enhance civic awareness, dedication and service with special difficulties for 4, and in need of help members of society to provide services
誰可以幫我翻譯一下我的個人簡曆?
Zhe Jiang Yu male sex
February 4, 1986 ethnic Han
Shuangliao City, Jilin Province, state of health of health
CPC party members and undergraduate education
Changchun University of Science and Technology College Professional Electronic Science and Technology
13756178898 address Changchun University of Science and Technology College classes 0,501,312
130022 E-mail Jiangyz1986@sina.com
6 English national computer national level II computer can OFFICE proficiency, and other office applications.
2005-2009 College 05-year long ban 0,501,004 squad chief 0,501,312
2005-2009 with 65,301 troops and stop the supply of oil Changchun soldiers and civilians to build the school on behalf of the
2006-2007 President of the College Students
2006 Changchun City, Europe and Asia are "Samsung" booth sales assistant
June 2006 Watson Changchun Optoelectronic Co., Ltd. Practice
In July 2006 of the "three rural areas" and volunteers condolence "mother agent" of children
April 2007 Changchun FAW Group Corporation production internship
April 2007 the state-owned factory on February 28, 5514 production internship
Students in the work of the presidency during the New Year house party organized by several times, Games, Acting mother handover ceremony, sports competitions, knowledge contests, dance contest, the ten best singers, such as large-scale competition.
2005-2006 Changchun City College Top 10 squad civilization classes; outstanding member of Changchun C......餘下全文>>