codeforce 1189C Candies! ----前缀和
题目大意:给你一个数组每个数不大于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! ----前缀和的更多相关文章
- codeforces 1189C Candies! / 前缀和
http://codeforces.com/problemset/problem/1189/C 求一下前缀和,给定区间的数字和除以10就是答案 AC代码: #include<iostream&g ...
- Codeforces 1189C Candies!
题目链接:http://codeforces.com/problemset/problem/1189/C 思路:前缀和. AC代码: #include<bits/stdc++.h> usi ...
- #C++初学记录ACM补题(D. Candies!)前缀和运算。
D - Candies! Consider a sequence of digits of length [a1,a2,-,a]. We perform the following operati ...
- 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 ...
- Codeforce 水题报告(2)
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...
- 【树状数组】区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D
[树状数组]区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D PROBLEM 题目描述 初始给定n个卡片拍成一排,其中第i个卡片上的数为x[i]. 有q个询问,每次询问 ...
- Tanya and Candies
Tanya and Candies time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- HDU 5291 Candy Distribution DP 差分 前缀和优化
Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of ...
- Codeforce 1175 D. Array Splitting
新鲜热乎的题 Codeforce 1175 D. 题意:给出一个长度为$n$的序列$a$,你需要把它划分为$k$段,每一个元素都需要刚好在其中一段中.分好之后,要计算$\sum_{i=1}^{n} ( ...
随机推荐
- oracle(3)select语句中常用的关键字说明
1.select 查询表中的数据 select * from stu: ---查询stu表所有的数据,*代表所有2.dual ,伪表,要查询的数据不存在任何表中时使用 select sysdate f ...
- 19 01 18 dango 模型
定义属性 Django根据属性的类型确定以下信息: 当前选择的数据库支持字段的类型 渲染管理表单时使用的默认html控件 在管理站点最低限度的验证 django会为表创建自动增长的主键列,每个模型只能 ...
- C++ STD Gems03
transform.for_each #include <iostream> #include <vector> #include <string> #includ ...
- 寒假day25
今天解决了部分数据爬取不下来的问题,同时进行了面试的准备
- Sequence Models Week 1 Improvise a Jazz Solo with an LSTM Network
Improvise a Jazz Solo with an LSTM Network Welcome to your final programming assignment of this week ...
- C++ 操作数据库类
#pragma once #include <string> #include <windows.h> #include <algorithm> #include ...
- JavaScript 之 异步请求
一. 1.异步(async) 异步,它的孪生兄弟--同步(Synchronous),"同步模式"就是上一段的模式,后一个任务等待前一个任务结束,然后再执行,程序的执行顺序与任务的排 ...
- 设置MySQL客户端连接使用的字符集
设置MySQL客户端连接使用的字符集 时间:2014-03-05 来源:服务器之家 投稿:root 考虑什么是一个"连接":它是连接服务器时所作的事情.客户端发送SQL ...
- Nginx无法监听虚拟VIP的问题报:99: Cannot assign requested address
99: Cannot assign requested address #本地网卡上没有10.0.0.3这个IPNginx就会报错: [root@lb01 conf]# /application/ng ...
- PAT Advanced 1102 Invert a Binary Tree (25) [树的遍历]
题目 The following is from Max Howell @twitter: Google: 90% of our engineers use the sofware you wrote ...