#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. Android Intent传递对象小结

    效果: 想看实例的,感兴趣的能够看之前的一篇文章 Android ViewPager Fragment实现选项卡 部分关键代码: public class SerializeActivity exte ...

  2. [Angular 2] Inject Service

    TypeScript is used heavily as we build up our application, but TypeScript isn’t required. If you wan ...

  3. 多线程下的performSelector和NSThread的使用

    多线程下的performSelector和NSThread的使用 NSThread的多线程使用: 我们可以使用这两种方法来使用线程中的问题 - (id)initWithTarget:(id)targe ...

  4. 对于android拦截短信的一些疑问

    最近折腾android4.4短信拦截的问题,要求在app上收到短信的时候弹出提示,并显示的功能. 然后找到了使用broadcastreceiver和contentprovider两种方法,那么问题来了 ...

  5. Sublime Text3使用详解

    Sublime Text简介 Sublime Text - 性感的代码编辑器.程序员之必备神器 Sublime Text 是一个代码编辑器,也是HTML和散文先进的文本编辑器.Sublime Text ...

  6. UniqueID和ClientID的来源

    在<漫话ID>一文中,作者提出了一个问题:为什么在ItemCreated事件中访问ClientID会导致MyButton无法响应事件,事实上 MyButton无法响应事件是因为他在客户端的 ...

  7. 【转】overload与override的区别

    [转]overload与override的区别 override(重写,覆盖) 1.方法名.参数.返回值相同. 2.子类方法不能缩小父类方法的访问权限. 3.子类方法不能抛出比父类方法更多的异常(但子 ...

  8. 【javascript模式】Chapter2: 基本 技巧

    1 尽量少用全局变量,最好一个应用程式只有一个全局变量  隐含全局变量(不使用var声明)与明确定义的全局变量区别:  (1)使用var创建的全局变量(在函数外部声明)不能用delete删除  (2) ...

  9. SQL批量信息保存(XML格式字符串数据)

    /* *功能:SQL批量信息录入 *此存储过程获取表单信息,插入表中.*/CREATE  PROC [dbo].[sp_SaveToMX1]@XML text   --明细表XML字符串信息ASBEG ...

  10. 困扰:C#.net 连接Oracle11g 不报错但是在connection时出现 ServerVersion 引发了“System.InvalidOperationException”类型的异常

    今天在使用VS2008 32位 连接 64位的Oracle11g的数据库时出现 “conn.ServerVersion”引发了“System.InvalidOperationException”类型的 ...