链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=690&pid=1001
我用线段树过的~可能要注意a,b的关系
 #include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x7fffffff
#define INFL 0x7fffffffffffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
const int N = ;
const int MOD = ;
using namespace std;
int num[N];
int ans;
char c[N];
struct node
{
int left;
int right;
int value;
}tree[N*];
void sum(int rt)
{
tree[rt].value = (tree[rt*].value*tree[rt*+].value)%MOD;
}
void build(int l,int r,int rt)
{
tree[rt].left=l;
tree[rt].right=r;
int m=(l+r)>>;
if(l==r)
{
tree[rt].value=num[l];
return;
}
build(lson);
build(rson);
tree[rt].value=(tree[rt*].value*tree[rt*+].value)%MOD;
}
void query(int l,int r,int rt)
{
if(l==tree[rt].left&&r==tree[rt].right)
{
ans=(ans*tree[rt].value)%MOD;
return ;
}
int m=(tree[rt].left+tree[rt].right)>>;
if(r<=m)
query(l,r,rt*);
else if(l>m)
query(l,r,rt*+);
else
{
query(l,m,rt*);
query(m+,r,rt*+);
}
}
int main()
{
int t;
while(~scanf("%d",&t))
{
scanf("%s",c);
int len=strlen(c);
for(int i=;i<len;i++)
{
num[i+]=c[i]-;
}
build(,N,);
for(int i=;i<t;i++)
{
ans=;
int l,r;
scanf("%d%d",&l,&r);
if(l>r)
{
swap(l,r);
}
query(l,r,);
printf("%d\n",ans);
}
}
return ;
}

2016"百度之星" - 资格赛(Astar Round1) A的更多相关文章

  1. 2016百度之星 资格赛ABCDE

    看题:http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=690 交题:http://acm.hdu.edu.cn/search.php ...

  2. HDU 5688:2016"百度之星" - 资格赛 Problem D

    原文链接:https://www.dreamwings.cn/hdu5688/2650.html Problem D Time Limit: 2000/1000 MS (Java/Others)    ...

  3. HDU 5686:2016"百度之星" - 资格赛 Problem B

    原文链接:https://www.dreamwings.cn/hdu5686/2645.html Problem B Time Limit: 2000/1000 MS (Java/Others)    ...

  4. HDU 5685:2016"百度之星" - 资格赛 Problem A

    原文链接:https://www.dreamwings.cn/hdu5685/2637.html Problem A Time Limit: 2000/1000 MS (Java/Others)    ...

  5. 2016"百度之星" - 资格赛(Astar Round1)

    逆元 1001 Problem A 求前缀哈希和逆元 #include <bits/stdc++.h> typedef long long ll; const int MOD = 9973 ...

  6. 2016"百度之星" - 资格赛(Astar Round1) 1004

    思路:题目很简单,直接用map记录每个字符串的个数就可以了.记得对每个字符串先sort(). AC代码: #include <cstdio> #include <stdlib.h&g ...

  7. 2016"百度之星" - 资格赛(Astar Round1) 1001

    思路:第一个做法就是:每读入起始位置i和结束位置j,就从这位置i到位置j计算,可是TLE了,后面我想想要是我输入一个最长的字符串,且以最大次数计算开始位置1到结束位置100000,那么这计算量是很大的 ...

  8. 2016"百度之星" - 资格赛(Astar Round1) Problem E

    简单模拟题,耐心写就能过. #include <stdio.h> #include <math.h> #include<cstring> #include<c ...

  9. 2016"百度之星" - 资格赛(Astar Round1) Problem C

    字典树. 插入的时候update一下节点出现的次数. delete的时候,先把前缀之后的全删了.然后看前缀最后一个节点出现了几次,然后前缀上每个节点的次数都减去这个次数. 前缀从上到下再检查一遍,如果 ...

  10. 2016"百度之星" - 资格赛(Astar Round1) Problem D

    排个序,map直接搞. #include <stdio.h> #include <math.h> #include<cstring> #include<cma ...

随机推荐

  1. 基于aspectj的aop注解操作

  2. c语言中argc和argv

    main函数的参数,解释如下: argc:命令行总的参数的个数,即argv中元素的格式. *argv[ ]:字符串数组,用来存放指向你的字符串参数的指针数组,每一个元素指向一个参数. argv[0]: ...

  3. MyBatis总结一:快速入门

    简介 MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射.MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集.MyBatis 可以使用简单的 ...

  4. [patl2-018]多项式A除以B

    解题关键:多项式除法的模拟. #include<cstdio> #include<cstring> #include<algorithm> #include< ...

  5. a标签中href=""的几种用法(转)

    a标签中href=""的几种用法   标签: html / a标签 / javascript 46371 众所周知,a标签的最重要功能是实现超链接和锚点.而且,大多数人认为a标签最 ...

  6. return()函数

    在函数中,执行完return()函数后,下面的语句就不会再执行了.例子: <?php function fn() { echo "you are awsome"; retur ...

  7. sequelize 用于PostgreSQL,MySQL,SQLite和MSSQL的Node.js / io.js ORM

    安装 Sequelize可通过NPM获得. $ npm install --save sequelize # And one of the following: $ npm install --sav ...

  8. 获取当前设备的CPU个数

    public class Test { public static void main(String[] args) { //获取当前设备的CPU个数 int availableProcessors ...

  9. BuilderPattern(23种设计模式之一)

    设计模式六大原则(1):单一职责原则 设计模式六大原则(2):里氏替换原则 设计模式六大原则(3):依赖倒置原则 设计模式六大原则(4):接口隔离原则 设计模式六大原则(5):迪米特法则 设计模式六大 ...

  10. Luogu 1514 [NOIP2010] 引水入城

    我就是过来开心一下……这道题从开坑以来已经堆积了大半年了……今天才发现广搜一直写挂…… 丢个线段覆盖的模板,设$f_{i}$表示覆盖区间[1, i]的最小代价,$g_{i, j}$表示覆盖区间[i, ...