题目链接:http://codeforces.com/problemset/problem/1189/C


思路:前缀和。

AC代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 +;
int a[maxn];
int n, m;
int ask(int x,int y)
{
return (a[y] - a[x-])/;
}
int main()
{
cin >> n;
int x , y;
for(int i = ;i <= n;i++)
{
cin >> a[i];
a[i] += a[i-];
}
cin >> m;
while(m--)
{
cin >> x >> y;
cout << ask(x,y) << endl;
}
return ;
}

Codeforces 1189C Candies!的更多相关文章

  1. codeforces 1189C Candies! / 前缀和

    http://codeforces.com/problemset/problem/1189/C 求一下前缀和,给定区间的数字和除以10就是答案 AC代码: #include<iostream&g ...

  2. Codeforces 1063D Candies for Children

    题目大意 给定整数 $n, k, l, r$,$1\le n, k \le 10^{11}$,$1\le l, r \le n$ . 令 $ m = r - l + 1$,若 $m \le 0$,$m ...

  3. CF思维联系– CodeForces - 991C Candies(二分)

    ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal am ...

  4. codeforce 1189C Candies! ----前缀和

    题目大意:给你一个数组每个数不大于9,然后给你m个区间,每个区间的长度都是2的k次方(k=0 1 2.....)  有一种操作是把奇数位和偶数位相加  用和来代替之前的两个数,如果和大于等于10就要膜 ...

  5. ACM思维题训练 Section A

    题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...

  6. Codeforces Round #588 (Div. 2) A. Dawid and Bags of Candies

    链接: https://codeforces.com/contest/1230/problem/A 题意: Dawid has four bags of candies. The i-th of th ...

  7. Codeforces Zepto Code Rush 2014 -C - Dungeons and Candies

    这题给的一个教训:Codeforces没有超时这个概念.本来以为1000*(1000+1)/2*10*10要超时的.结果我想多了. 这题由于k层都可能有关系,所以建一个图,每两个点之间连边,边权为n* ...

  8. Codeforces Round #234 (Div. 2) B. Inna and New Matrix of Candies

    B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...

  9. Divide Candies CodeForces - 1056B (数学)

    Arkady and his friends love playing checkers on an n×nn×n field. The rows and the columns of the fie ...

随机推荐

  1. 框架-.NET:ASP.NET MVC

    ylbtech-框架-.NET:ASP.NET MVC ASP.NET MVC 是Windows系统下面的Web研发框架,有Microsoft提供.MVC顾名思义:Model, View, Contr ...

  2. CompletableFuture提高你并发编程能力

    思考:如果有两个顺序执行耗时的方法,你该怎么做??? 例如: public void doHousework() { //烧水 doWater(); //扫地 doFloor(); } 没错,聪明如我 ...

  3. centos python3.7 报错 No module named ‘_ctypes’ make: ***

    1.先装好python的依赖 2.yum install libffi-devel -y(解决)

  4. charles使用教程

    概述 Charles是目前最强大的http调试工具,在界面和功能上远胜于Fiddler,同时是全平台支持.是收费软件,可以试用15分钟,下面提供了破解方法.   安装破解 https://www.cn ...

  5. C语言博客作业02

    2.1 一.请仔细阅读<提问的智慧>,用自己的话描述你的收获,并举例子说明应该如何提问. 答:1.提问是思考的另一种方式,一个好的提问能体现出我们在认真的,聪明的思考; 2.做什么事情都要 ...

  6. shell 跟踪命令

    添加跟踪 set -x 去除跟踪 set +x

  7. spark复习总结02

    1.spark执行原理图 spark程序启动后创建sparkContext作为程序的入口,sparkContext可以与不同类的集群资源管理器(Cluster Manager)进行通信,从而获得程序运 ...

  8. >>> print "hello" SyntaxError: Missing parentheses in call to 'print'

    错误原因说你的函数print缺省圆括号,可以知道你用的python是3.x版本3.x版本的python,print中的参数要用圆括号括起来,改成:print("hello")

  9. android 样式和主题

  10. vue aliasConfig(模块别名配置)

    今天研究了下鹏哥搭建的项目代码,一个人捣鼓了半天模块别名配置,边写边测试,才慢慢明白,所有写下来当个笔记: 在vue项目中,经常根据需要引入不同的功能模块,默认情况下我们通过代码 import mod ...