#include <cstdio>
#include <cstring>
#include <cstdlib> #define MAXN 100005
#define MOD 1000000007
int que[MAXN], front = , rear = ;
int n; void query(int index) {
int r = rear;
int square = ;
int half = (n+)>>; while (r-- > front) {
if (que[r] == ) {
++square;
} else if (que[r] == ) {
index = n+-index;
} else {
if (index > half) {
index = (index - half)*;
} else {
index = *index - ;
}
}
}
__int64 ret = index%MOD;
for (int i=; i<square; ++i) {
ret = ret*ret%MOD;
}
printf("%I64d\n", ret);
} int main() {
int t, m;
int x;
char cmd[]; scanf("%d", &t);
while (t--) {
rear = ;
scanf("%d%d", &n, &m);
while (m--) {
scanf("%s %d", cmd, &x);
if (cmd[] == 'Q') {
query(x);
} else {
que[rear++] = x;
}
}
}
return ;
}

【HDOJ】5063 Operation the Sequence的更多相关文章

  1. 【HDOJ】5288 OO’s Sequence

    二分寻找对于指定pos的最左因数点和最右因数点. /* 5288 */ #include <iostream> #include <string> #include <m ...

  2. 【HDOJ】5057 Argestes and Sequence

    树状数组,其实很简单.只是MLE. #include <iostream> #include <cstdio> #include <cstring> using n ...

  3. 【BZOJ1345】[Baltic2007]序列问题Sequence 贪心+单调栈

    [BZOJ1345][Baltic2007]序列问题Sequence Description 对于一个给定的序列a1, …, an,我们对它进行一个操作reduce(i),该操作将数列中的元素ai和a ...

  4. HDU 5063 Operation the Sequence(暴力)

    HDU 5063 Operation the Sequence 题目链接 把操作存下来.因为仅仅有50个操作,所以每次把操作逆回去执行一遍,就能求出在原来的数列中的位置.输出就可以 代码: #incl ...

  5. HDOJ 5063 Operation the Sequence

    注意到查询次数不超过50次,那么能够从查询位置逆回去操作,就能够发现它在最初序列的位置,再逆回去就可以求得当前查询的值,对于一组数据复杂度约为O(50*n). Operation the Sequen ...

  6. hdu 5063 Operation the Sequence(Bestcoder Round #13)

    Operation the Sequence                                                                     Time Limi ...

  7. 【SPOJ】1182 Sorted bit sequence

    [算法]数位DP [题解]动态规划 写了预处理函数却忘了调用是一种怎样的体验? #include<cstdio> #include<cstring> #include<a ...

  8. 【HDOJ】3397 Sequence operation

    线段树的应用,很不错的一道题目.结点属性包括:(1)n1:1的个数:(2)c1:连续1的最大个数:(3)c0:连续0的最大个数:(4)lc1/lc0:从区间左边开始,连续1/0的最大个数:(5)rc1 ...

  9. 【HDOJ】2062 Subset sequence

    这道题目非常好,饶了点儿圈子.我的思路是,先按照组排列.例如,1            2           31 2         2 1        3 11 2 3      2 1 3  ...

随机推荐

  1. 自动开机和自动关机设定方法(包括linux和windows)

    (一) linux 机器 1.关机 : 编辑 /etc/crontab添加一条并且保证crontab服务的运行即可 f1 f2 f3 f4 f5 root sudo shutdown –h now 假 ...

  2. Delphi系统托盘组件 TTrayIcon 简介

    TTrayIcon 的主要属性: TrayIcon.Icon指定托盘图标, 有几种用法:1.设计时选择;2.把一个 TIcon 对象给它;3.使用当前程序图标: TrayIcon1.Icon := A ...

  3. 概率dp-九度-1546-迷宫问题

    题目链接: http://ac.jobdu.com/problem.php?pid=1546 题目意思: 有一个起点S,多个出口E,#代表不能走,每次等概率的随机选择下一个可以行走的位置,求从S到出口 ...

  4. 2013ACM暑假集训总结-致将走上大三征途的我

    回想起这个暑假,从开始与雄鹰一起的纠结要不要进集训队,与吉吉博博组队参加地大邀请赛,害怕进不了集训队.当时激励我月份开始接触的,记得当时在弄运动会来着,然后就问了雄鹰一些输入输出的东西,怀着满心的期待 ...

  5. [Javascript] String method: endsWith() && startsWith()

    With endsWith && startsWith, you can easily find out whether the string ends or starts with ...

  6. js中return false,return,return true的使用方法及区别

    起首return作为返回keyword,他有下面两种返回体式格式 1.返回把握与函数成果 语法为:return 表达式; 语句停止函数履行,返回调用函数,而且把表达式的值作为函数的成果 2.返回把握无 ...

  7. 会用errno,事半功倍

    参考一 参考二 参考三 参考四 一. errno二. 把errno的数字转换成相应的文字说明1. 使用strerror函数2. 使用perror函数三. errno的线程/进程安全性附录 一. err ...

  8. AES对称加密算法

    package cn.jsonlu.passguard.utils; import org.apache.commons.codec.binary.Base64; import javax.crypt ...

  9. xls和xlsx

      xls XLS 就是 Microsoft Excel 工作表,是一种非常常用的电子表格格式.xls文件可以使用Microsoft Excel打开,另外微软为那些没有安装Excel的用户开发了专门的 ...

  10. 【转】iOS开发系列--数据存取

    原文: http://www.cnblogs.com/kenshincui/p/4077833.html#SQLite 概览 在iOS开发中数据存储的方式可以归纳为两类:一类是存储为文件,另一类是存储 ...