题目大意:给你一个数组每个数不大于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. C++编程学习(三)运算符

    一.运算符 1.求余运算双方必须是整数. 2.编程时一定要注意运算符的优先级!!!例如: int a=5,b=6,c=6,k; 3>4 //结果为假 a<b //结果为真 k= b!=c ...

  2. Python Learning Day6

    selenium操作 点击.清除操作 from selenium import webdriver from selenium.webdriver.common.keys import Keys im ...

  3. matlab中自带的sobol的函数提供的sobol序列

    clc; clear all; close all; M=;% 维度,几个参数 nPop=; VarMin=[0.6, 0.10, 0.002, 0.02, 0.17, 0.0, 0.17, 0.0, ...

  4. pyCharm中设置查看运行过程中的变量实时情况

    1.点击运行栏的这个灰色向下剪头: 2.单击“Edit Configurations”, 3.在出现的窗口上,勾选上:“Show command line afterwards” 或 “run wit ...

  5. spring boot 环境配置(profile)切换

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  6. C#窗体与SQL数据库的连接

    /*通过C#winform程序访问数据库数据 用到的命名空间和变量类型: using System.Data.SqlClient; SqlConnection:数据库连接类 SqlCommand:数据 ...

  7. POJ 1011:Sticks 经典搜索

    Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 128734   Accepted: 30173 Descrip ...

  8. 洛谷 P2719 搞笑世界杯

    题目传送门 解题思路: f[i][j]表示买i张A票,j张B票的概率. AC代码: #include<iostream> #include<cstdio> using name ...

  9. JS添加、设置属性以及鼠标移入移出事件

    源代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  10. js 动态添加元素 删除元素逻辑

    js 动态添加元素 删除元素逻辑 var obox=document.getElementById("box"); oadd.onclick=function(){ var odi ...