HDU 5063 Operation the Sequence(暴力)
来源:互联网 发布:微谱数据库怎么检索 编辑:程序博客网 时间:2024/05/21 22:23
HDU 5063 Operation the Sequence
题目链接
把操作存下来,由于只有50个操作,所以每次把操作逆回去运行一遍,就能求出在原来的数列中的位置,输出即可
代码:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const int N = 100005;const ll MOD = 1000000007;int t, n, m, c;ll a[N];int op[N], on;char str[3];ll pow_mod(ll x, ll k) {ll ans = 1;while (k) {if (k&1) ans = ans * x % MOD;x = x * x % MOD;k >>= 1;}return ans;}ll solve(int c) {ll mul = 1;for (int i = on - 1; i >= 0; i--) {if (op[i] == 1) {if (c > (n + 1) / 2) c = (c - (n + 1) / 2) * 2;else c = (c - 1) * 2 + 1;} else if (op[i] == 2) c = n - c + 1;else mul = mul * 2 % (MOD - 1);}return pow_mod(a[c], mul);}int main() {scanf("%d", &t);while (t--) {on = 0;scanf("%d%d", &n, &m);for (int i = 1; i <= n; i++) a[i] = i;while (m--) {scanf("%s%d", str, &c);if (str[0] == 'O') op[on++] = c;else printf("%lld\n", solve(c));}}return 0;}
1 0
- HDU 5063 Operation the Sequence(暴力)
- HDU 5063Operation the Sequence(暴力)
- HDU 5063 Operation the Sequence(暴力 数学)
- Operation the Sequence(HDU 5063)
- hdu 5063 Operation the Sequence(思路)
- HDOJ 5063 Operation the Sequence (优化后的暴力)
- hdu-5063 Operation the Sequence
- Hdu 5063 Operation the Sequence
- Hdu 5063 Operation the Sequence
- HDU 5063 Operation the Sequence
- hdu 5063 Operation the Sequence
- hdu 5063 Operation the Sequence(模拟)
- HDU 5063 - Operation the Sequence (置换)
- 【瞎搞】 HDU 5063 Operation the Sequence
- hdu 5063——Operation the Sequence
- HDU - 5036 Operation the Sequence
- hdu 5063 Operation the Sequence(Bestcoder Round #13)
- hdu 5063 Operation the Sequence (数学公式逆推)
- android绘制图表(二)
- 一个运算表达式带来的教训
- Ubuntu输入密码登陆后又跳回到登录界面
- JavaBean的内省操作
- 项目一
- HDU 5063 Operation the Sequence(暴力)
- VS2013编译64位OpenSSL
- 【iOS开发-39】为什么按钮点击时背景图片颜色灰蒙蒙的?与按钮的Type属性有关
- 事务相关知识点
- 【Unity3D】主角平缓旋转
- static作用(修饰函数、局部变量、全局变量)
- 项目二
- 【Unity3D】Delegate
- 项目三