【HDOJ】5063 Operation the Sequence
2024-08-29 10:50:16
#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 ;
}
最新文章
- Notepade ++ 替换每行最后的换行符
- jQuery监听键盘事件及相关操作使用教程
- gitingore
- [转] - SendMessage、PostMessage原理
- 引擎设计跟踪(九.14.2i) Android GLES 3.0 完善
- Spring+MyBatis实践—登录和权限控制
- Eclipse中Cannot find any provider supporting DES解决之道
- redis 系列13 集合对象
- python语言的基本要素
- HIT2019春软件构造->;重写hashCode()方法
- spring cloud+.net core搭建微服务架构:配置中心续(五)
- flask 使用宏渲染表单(包含错误信息)
- python零散补充与总结
- bzoj4271: chemistry 化学
- ecloipse背景修改豆沙
- [NOIp2016]蚯蚓 (队列)
- python基础之collections模块
- 剑指offer——面试题29:顺时针打印矩阵
- linux 命令行基础
- 使用spring-loaded实现应用热部署
热门文章
- 搭建自己的SIPserver:开源sipserveropensips的搭建及终端TwInkle的使用
- CreateFont具体解释
- linux中 vi / vim显示行号或取消行号命令
- [转] HBase的特征和优点
- Java基础知识强化之IO流笔记11:递归之递归概述和注意事项
- TCP/IP协议原理与应用笔记10:TCP/IP协议族
- discuz! X3 门户文章添加字段
- C#解leetcode 219. Contains Duplicate II
- phonegap 2.8.1 toast
- Linux安装配置mongodb