【HDOJ】5063 Operation the Sequence
#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的更多相关文章
- 【HDOJ】5288 OO’s Sequence
二分寻找对于指定pos的最左因数点和最右因数点. /* 5288 */ #include <iostream> #include <string> #include <m ...
- 【HDOJ】5057 Argestes and Sequence
树状数组,其实很简单.只是MLE. #include <iostream> #include <cstdio> #include <cstring> using n ...
- 【BZOJ1345】[Baltic2007]序列问题Sequence 贪心+单调栈
[BZOJ1345][Baltic2007]序列问题Sequence Description 对于一个给定的序列a1, …, an,我们对它进行一个操作reduce(i),该操作将数列中的元素ai和a ...
- HDU 5063 Operation the Sequence(暴力)
HDU 5063 Operation the Sequence 题目链接 把操作存下来.因为仅仅有50个操作,所以每次把操作逆回去执行一遍,就能求出在原来的数列中的位置.输出就可以 代码: #incl ...
- HDOJ 5063 Operation the Sequence
注意到查询次数不超过50次,那么能够从查询位置逆回去操作,就能够发现它在最初序列的位置,再逆回去就可以求得当前查询的值,对于一组数据复杂度约为O(50*n). Operation the Sequen ...
- hdu 5063 Operation the Sequence(Bestcoder Round #13)
Operation the Sequence Time Limi ...
- 【SPOJ】1182 Sorted bit sequence
[算法]数位DP [题解]动态规划 写了预处理函数却忘了调用是一种怎样的体验? #include<cstdio> #include<cstring> #include<a ...
- 【HDOJ】3397 Sequence operation
线段树的应用,很不错的一道题目.结点属性包括:(1)n1:1的个数:(2)c1:连续1的最大个数:(3)c0:连续0的最大个数:(4)lc1/lc0:从区间左边开始,连续1/0的最大个数:(5)rc1 ...
- 【HDOJ】2062 Subset sequence
这道题目非常好,饶了点儿圈子.我的思路是,先按照组排列.例如,1 2 31 2 2 1 3 11 2 3 2 1 3 ...
随机推荐
- LinearLayout增加divider分割线
在android3.0及后面的版本在LinearLayout里增加了个分割线 1 2 android:divider="@drawable/shape"<!--分割线图片-- ...
- php 二维数组以树形输出(转)
<?php /** * @author Skyline * @copyright 2011 */ $cate = array(1=>array('id'=>1,'pid'=>0 ...
- 【iOS UISearchBar父控件是UIScrollView时,上移的问题】
如果UISearchViewController的父控件是UIScrollView,点击UISearchBar后,它会移出控制器外.如下,使用UIScrollView作为"消息"和 ...
- Volley框架使用(POST)
需要在MyApplication(继承Application)中配置; public static RequestQueue requestQueue; @Override public void o ...
- readonly 与 const
readonly MSDN定义:readonly 关键字是可以在字段上使用的修饰符.当字段声明包括 readonly 修饰符时,该声明引入的字段赋值只能作为声明的一部分出现,或者出现在同一类的构造函数 ...
- CI 中css样式或者js样式加载不进来的情况
首先,目录应该是放在根目录下面的,和 application 目录同级 然后再application\config\config.php ,将默认路径配置成为自己的本访问路径 $config['bas ...
- PHP magic_quotes_gpc的详细使用方法
工作中遇到的代码 if (ini_get('magic_quotes_gpc')) { function stripslashesRecursive(array $array){ foreach ($ ...
- Ajax简单应用-购物车
1. 2. 3. 4. 5. 6.
- Foudation框架之一些常用结构体和常用类
表示范围作用的结构体:NSRange: 有三种方式创建新的NSRange: 1.NSRange range: range.location = 17; ...
- 开始学习<p>标签,添加段落
如果想在网页上显示文章,这时就需要<p>标签了,把文章的段落放到<p>标签中. 语法: <p>段落文本</p> 注意一段文字一个<p>标签, ...