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 ...
随机推荐
- HTML5: HTML5 Web SQL 数据库
ylbtech-HTML5: HTML5 Web SQL 数据库 1.返回顶部 1. HTML5 Web SQL 数据库 Web SQL 数据库 API 并不是 HTML5 规范的一部分,但是它是一个 ...
- 53、tensorflow基本操作
import tensorflow as tf import numpy as np x_data = np.float32(np.random.rand(2,100)) print(x_data) ...
- toString()方法,与call()方法结合;用来进行数据类型检测
//toString()方法,与call()方法结合;用来进行数据类型检测 console.log(Object.prototype.toString.call([]));//'[object A ...
- NMS python实现
import numpy as np ''' 目标检测中常用到NMS,在faster R-CNN中,每一个bounding box都有一个打分,NMS实现逻辑是: 1,按打分最高到最低将BBox排序 ...
- gitlab+gitlab-ci+docker自动化部署
导言 本次测试用的是gitlab-ci,单纯与gitlab搭配而言,gitlab-ci较jenkins更加一体,顺畅. 主机1:192.168.100.151 gitlab 主机2:192.168.1 ...
- mysql中tinyint(1)与tinyint(2)的区别
tinyint 型的字段如果设置为UNSIGNED类型,只能存储从0到255的整数,不能用来储存负数.tinyint 型的字段如果不设置UNSIGNED类型,存储-128到127的整数. 1个tiny ...
- Mint安装配置Sublime Text3
1.注册码: Sublime Text 3 3126 注册码 2.安装Package Control组件: 按Ctrl+`调出console(注:安装有QQ输入法的这个快捷键会有冲突的,输入法属性设置 ...
- Spark Core 1.3.1源码解析及个人总结
本篇源码基于赵星对Spark 1.3.1解析进行整理.话说,我不认为我这下文源码的排版很好,不能适应的还是看总结吧. 虽然1.3.1有点老了,但对于standalone模式下的Master.Worke ...
- Thunar 右键菜单等自定义
Thunar 右键菜单等自定义 可以使用图形界面或者直接编辑配置文件,二者是等价的. 图形界面: 以给"zip,rar,7z"等文件添加"在此位置使用unar解压缩&qu ...
- SharpZipLib 文件/文件夹 过滤
这里就不说压缩/解压了.网上教程太多. 主要说一下,解压时,如何过滤某些文件/文件夹 参考地址:https://github.com/icsharpcode/SharpZipLib/wiki/Fast ...