Codeforces 1189C Candies!
题目链接: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!的更多相关文章
- codeforces 1189C Candies! / 前缀和
http://codeforces.com/problemset/problem/1189/C 求一下前缀和,给定区间的数字和除以10就是答案 AC代码: #include<iostream&g ...
- 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 ...
- CF思维联系– CodeForces - 991C Candies(二分)
ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal am ...
- codeforce 1189C Candies! ----前缀和
题目大意:给你一个数组每个数不大于9,然后给你m个区间,每个区间的长度都是2的k次方(k=0 1 2.....) 有一种操作是把奇数位和偶数位相加 用和来代替之前的两个数,如果和大于等于10就要膜 ...
- ACM思维题训练 Section A
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...
- 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 ...
- Codeforces Zepto Code Rush 2014 -C - Dungeons and Candies
这题给的一个教训:Codeforces没有超时这个概念.本来以为1000*(1000+1)/2*10*10要超时的.结果我想多了. 这题由于k层都可能有关系,所以建一个图,每两个点之间连边,边权为n* ...
- 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 ...
- 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 ...
随机推荐
- iiview Select 选择框打勾选中的内容label和展示的不一致
Select选择框里加入了OptionGroup.option ; 以及input输入框支持模糊搜索: 不一致的原因:缺少 :label-in-value="true";官方文档 ...
- elemeng-ui中el-select的默认选择项问题
直接绑定将option中的value值绑定给v-model <template> <div> <el-select v-model="query"&g ...
- Java 13 即将发布,新特性必须抢先看!
作者:h4cd 本文转载自开源中国(ID:oschina2013) 由于 Java 现在采取"半年发布一次新版本"的模式,所以 Java 12 的下一个版本 Java 13/JDK ...
- 【java】记录一下java的常用用法
1.二维数组 public static void main(String[] args) { //定义 int a[][] = {{1,2,3},{4,5,6},{7,8,9}}; int [][] ...
- BUUCTF MISC部分题目wp
MISC这里是平台上比较简单的misc,都放在一起,难一些的会单独写1,二维码图片里藏了一个压缩包,用binwalk -e分离,提示密码为4个数字,fcrackzip -b -c1 -l 4 -u 得 ...
- 《代码大全2》读书笔记 Week9
本周阅读了<代码大全2>第14章至第17章,这几章对我们熟悉的直线型代码.条件语句.循环语句和一些不常用的控制结构(如goto.try-catch结构)提出了一些使用建议,以下分享条件语句 ...
- ORACLE PL、SQL编程
PL(Procedural Language)过程化的编程语言,是在SQL的基础上增加的部分,如:变量的使用.流程控制等, 重点学习Oracle和MySQL创建存储过程及流程控制的异同. 一.存储过程 ...
- Stm32CubeMX5 创建LED控制工程 - 基于stmf051k8u6
一. 创建一个控制LED的工程 1. 安装好 Stm32CubeMX5 后 打开软件 选择 “ File--> New Project...” 创建一个新工程 2. 之后会出现一个选择芯片的窗 ...
- KiCAD批量修改丝印大小
KiCAD批量修改丝印大小 1.编辑->编辑文本与图片属性 2.范围 选择封装参考,活动 首选选择 “设定为指定值”,然后选择要修改的层,输入想要修改的参数 注意:文本高度与文本宽度比例要适中, ...
- ORA-01400: cannot insert NULL into
Error text: ORA-01400: cannot insert NULL into when insert into view, NULL value handler in trigger. ...