题目大意:给你一个数组每个数不大于9,然后给你m个区间,每个区间的长度都是2的k次方(k=0 1 2.....)  有一种操作是把奇数位和偶数位相加  用和来代替之前的两个数,如果和大于等于10就要膜10并且答案计数+1  。每一个区间询问你需要输出把这个区间的每队奇数位和偶数位不断相加取膜处理。问你最后只剩一个数的时候,取了几次膜。

分析:因为最后都是要加和到只剩一位的,所以直接前缀和然后再除10就是答案了

#include<bits/stdc++.h>
using namespace std;
long long i,n,k,x,m;
long long a[];
int main()
{
cin>>n;
for(i=;i<=n;i++)
{
cin>>x;
a[i]=a[i-]+x;
}
cin>>m;
for(i=;i<m;i++)
{
cin>>x>>k;
cout<<(a[k]-a[x-])/<<endl;
}
}

codeforce 1189C Candies! ----前缀和的更多相关文章

  1. codeforces 1189C Candies! / 前缀和

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

  2. Codeforces 1189C Candies!

    题目链接:http://codeforces.com/problemset/problem/1189/C 思路:前缀和. AC代码: #include<bits/stdc++.h> usi ...

  3. #C++初学记录ACM补题(D. Candies!)前缀和运算。

    D - Candies!   Consider a sequence of digits of length [a1,a2,-,a]. We perform the following operati ...

  4. codeforce 1311 C. Perform the Combo 前缀和

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  5. Codeforce 水题报告(2)

    又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...

  6. 【树状数组】区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D

    [树状数组]区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D PROBLEM 题目描述 初始给定n个卡片拍成一排,其中第i个卡片上的数为x[i]. 有q个询问,每次询问 ...

  7. Tanya and Candies

    Tanya and Candies time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  8. HDU 5291 Candy Distribution DP 差分 前缀和优化

    Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of ...

  9. Codeforce 1175 D. Array Splitting

    新鲜热乎的题 Codeforce 1175 D. 题意:给出一个长度为$n$的序列$a$,你需要把它划分为$k$段,每一个元素都需要刚好在其中一段中.分好之后,要计算$\sum_{i=1}^{n} ( ...

随机推荐

  1. 字符,字符串,int之间互相转换

    字符转换成字符串:String str = String.valueOf(ch); 字符转换成int: int a = ch; 字符串转换成字符:char ch = str.charAt(0); 字符 ...

  2. Aizu 2155 Magic Slayer 背包DP

    这是上上次对抗赛的题目了 其实现在发现整个代码从头到尾,都是用了背包,怪我们背包没深入学好. 比赛的时候,聪哥提出的一种思路是,预处理一下,背包出 ALL攻击 和 single攻击的 血量对应的最小花 ...

  3. SQL inner join, join, left join, right join, full outer join

    基本信息 创建两个表a1, a2. 两个表的重要差别是:a1 中有5,'wu',a2中没有. a2中有 4,'li',而a1中没有. 创建表和插入数据的代码如下: -- 创建a1表 create ta ...

  4. HttpServletRequest 的常用属性说明

    HttpServletRequest 的常用属性总是被窝遗忘,人老了记性就不好.所以做个笔记,方便以后查看. 测试地址:http://127.0.0.1:8080/Test/test getConte ...

  5. torch.Tensor文档学习笔记

    A torch.Tensor is a multi-dimensional matrix containing elements of a single data type. 张量(torch.Ten ...

  6. JS-表单验证二

    3.范围验证:年龄范围验证: <head> <meta http-equiv="Content-Type" content="text/html; ch ...

  7. css 字符过长...

    text-overflow: ellipsis; white-space: nowrap; overflow: hidden; overflow: hidden; white-space: nowra ...

  8. java课程之团队开发冲刺阶段1.10

    一.总结昨天任务: 1.已完成系统规划总结 二.遇到的问题: 1,整合的过程中并没有的很好的处理其中的关系,应当将常用的方法总结成一个工具类便于使用.这样在二次使用的时候会便捷不少. 三.今天的任务 ...

  9. mysql5.7.21源码安装

    1.下载安装包 MySQL 官方下载地址:https://dev.mysql.com/downloads/mysql/  MySQL 5.7官方安装文档:https://dev.mysql.com/d ...

  10. 简单的Vue计算属性

    倒转字符串 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...