题目链接: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. 优化问题及KKT条件

    整理自其他优秀博文及自己理解. 目录 无约束优化 等式约束 不等式约束(KKT条件) 1.无约束优化 无约束优化问题即高数下册中的 “多元函数的极值"  部分. 驻点:所有偏导数皆为0的点: ...

  2. cs224d 作业 problem set2 (一) 用tensorflow纯手写实现sofmax 函数,线性判别分析,命名实体识别

    Hi Dear Today we will use tensorflow to implement the softmax regression and linear classifier algor ...

  3. 88、使用tensorboard进行可视化学习,查看具体使用时间,训练轮数,使用内存大小

    ''' Created on 2017年5月23日 @author: weizhen ''' import os import tensorflow as tf from tensorflow.exa ...

  4. 用FastDFS一步步搭建图片服务器(单机版)

    一.FastDFS介绍 FastDFS开源地址:https://github.com/happyfish100 参考:分布式文件系统FastDFS设计原理 参考:FastDFS分布式文件系统 1.简介 ...

  5. mac查看python安装路径

    1.terminal : input: which Python 或者 which Python3 2.terminal: input : python  --->import sys  --- ...

  6. 大数据学习之BigData常用算法和数据结构

    大数据学习之BigData常用算法和数据结构 1.Bloom Filter     由一个很长的二进制向量和一系列hash函数组成     优点:可以减少IO操作,省空间     缺点:不支持删除,有 ...

  7. Eclipse转idea改设置

    1 自动导包:画圈的打钩,实现自动导包,去除无用包.导入的类名相同时需要自己手动导包->  alt+enter. 2:修改快捷键 左移光标,右移同理. 上移光标:下移同理 光标移至行首,行末为e ...

  8. 嵌入式C语言4.2 C语言内存空间的使用-指针与修饰符:const,volatile,typedef

    const:变量,只读[不能变] 内存属性: 1. 内存操作的大小 2.内存的变化性,可写可读 char *p; const char *p;     描述字符串,p指向的内容是只读的,不可再次修改 ...

  9. vue-cli3.0打包完自动压缩zip

    打包是我们常见的操作 一般打包完还需要压缩丢到服务器解压 首先 我们需要一个 filemanager-webpack-plugin npm i filemanager-webpack-plugin - ...

  10. PAT甲级——A1146 TopologicalOrder【25】

    This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topol ...