博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu-5063 Operation the Sequence
阅读量:4286 次
发布时间:2019-05-27

本文共 1704 字,大约阅读时间需要 5 分钟。

题意:给你三种操作,然后询问当前第i个数的值

1、先奇后偶

2、对称交换

3、对每个数平方

题解:可以对询问的第i个位置逆推,求平方即可;

#include
#include
#include
#include
using namespace std;typedef __int64 LL;const LL MOD = 1000000007;char a[100005][1];int b[100005];LL Pow(LL A,LL B){ LL res = 1; while(B){ if(B&1) res = res * A % MOD; A = A * A % MOD ; B /= 2; } return res;}int main(){ int t,n,m; cin >> t; while(t--){ cin >> n >> m; int x = (n+1)/2; for(int i = 1;i <= m;i++){ scanf("%s %d",a[i],&b[i]); if(a[i][0] == 'Q') { LL p = 1; int pos = b[i]; for(int j = i-1;j >= 1;j--){ if(a[j][0] == 'O'){ if(b[j] == 1){// cout << " wqew " << endl; if(pos <= x) pos = pos + (pos - 1); else pos = (pos - x) * 2; } else if(b[j] == 2){// cout << " wqew " << endl; if(n%2){ pos = 2 * x - pos; } else{ pos = 2 * x - pos + 1; } } else{ p = p * 2 % (MOD - 1); } } }// cout << pos << "====" << p << endl; LL x = pos; x = Pow(x,p); cout << x << endl; } } }}

转载地址:http://fdsgi.baihongyu.com/

你可能感兴趣的文章
MAC系统PKG文件和DMG文件有哪些区别&VMWare安装Mac OS
查看>>
JQuery的tree显示处理插件
查看>>
Asp.Net 5.0简介
查看>>
C# DBNull和null说明
查看>>
Json序列化中null字段说明
查看>>
JQuery的表单验证之JQuery.validate插件
查看>>
vs 提示图标的含义
查看>>
AngularJS 常见错误
查看>>
CND使用说明整理2、Asp.NetCDN服务地址
查看>>
Require.Js简介
查看>>
RequireJS实例
查看>>
AngularJS路由
查看>>
AngularJS路由之ui-router(一)
查看>>
AngularJS路由之ui-router(二)
查看>>
Uncaught Error: datetimepicker component should be placed within a relative positioned container
查看>>
C#进制转换操作(一)
查看>>
C#进制转换操作(二)
查看>>
C#双规获取指定层数的下标排列
查看>>
C#转固定长度字符串
查看>>
JQuery.validationEngine表单验证插件
查看>>