题目链接: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. HTML-参考手册: 按字母顺序排列

    ylbtech-HTML-参考手册: 按字母顺序排列 1.返回顶部 1. 按字母顺序排列 New : HTML5新标签 标签 描述 <!--...--> 定义注释 <!DOCTYPE ...

  2. 基于rem的移动端响应式适配方案(详解) 移动端H5页面的设计稿尺寸大小规范

    基于rem的移动端响应式适配方案(详解) : https://www.jb51.net/article/118067.htm 移动端H5页面的设计稿尺寸大小规范 http://www.tuyiyi.c ...

  3. [已解决]报错: TLS handshake timeout

    为了永久性保留更改,您可以修改 /etc/docker/daemon.json 文件并添加上 registry-mirrors 键值. { "registry-mirrors": ...

  4. Emacs 25.1 error solved: url-http-create-request: Multibyte text in HTTP request

    Emacs 25.1 error solved: url-http-create-request: Multibyte text in HTTP request */--> code {colo ...

  5. Javafx弹窗

    在javafx中可能用到一些弹窗,比如点击某个按钮后弹出弹窗提示信息等等 Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle( ...

  6. CSS新特性(3D转换,perspective(透视),transfrom-style(子元素是否开启三维环境))

    1. 三维坐标系(里面的值不能省略,没有就写 0 ) x 轴:水平向右    注意:x 右边是正值,左边是负值 y轴: 垂直向下    注意:y 下面是正值,上面是负值 z轴:垂直屏幕     注意: ...

  7. swagger2.0与spring结合

    官方文档: http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api   swagger是一个前后端api统一文档和测试框 ...

  8. Android Service完全解析(上)

    转载:http://blog.csdn.net/guolin_blog/article/details/11952435 相信大多数朋友对Service这个名词都不会陌生,没错,一个老练的Androi ...

  9. Apache Hadoop集群离线安装部署(二)——Spark-2.1.0 on Yarn安装

    Apache Hadoop集群离线安装部署(一)——Hadoop(HDFS.YARN.MR)安装:http://www.cnblogs.com/pojishou/p/6366542.html Apac ...

  10. 停止node进程

    运行vue-cli项目的时候经常出现端口号占用,npm run dev报错的信息, 此时可通过任务管理器粗暴的杀死node进程,也可以通过cmd检测占用某个端口的程序,进而杀死该进程,步骤如下: 1. ...