hdu 5063——Operation the Sequence
来源:互联网 发布:如何在淘宝买bt种子 编辑:程序博客网 时间:2024/05/18 03:31
代码如下:
#include<iostream>#include<cstdio>#include<cstring>using namespace std;typedef long long ll;const int mod=1000000007;int operat[100005];int tot;int n,m;int fun1(int x)//第一个函数是把奇数放前面偶数放后面,这个相当于题目给的函数的反函数,得到了一个位置x,推出经过第一个函数之前x的位置{ int odd=n>>1; if(n&1)odd++; if(x<=odd)return 2*x-1; else { x-=odd; return 2*x; }}int fun2(int x)//第二个函数的反函数{ return n+1-x;}ll ans(ll x){ int mul=0; for(int i=tot-1;i>=0;--i) { if(operat[i]==1) { x=fun1(x); } else if(operat[i]==2) { x=fun2(x); } else { mul++;//乘方记下来,最后再乘 } } for(int i=1;i<=mul;++i) { x=x*x%mod; } return x;}int main(){// freopen("data.txt","r",stdin); int T; scanf("%d",&T); while(T--) { tot=0; scanf("%d%d",&n,&m); getchar(); for(int i=0;i<m;++i) { char op; int d; scanf("%c %d",&op,&d); getchar(); if(op=='O') { operat[tot++]=d; } else { printf("%I64d\n",ans((ll)d)); } } } return 0;}
0 0
- 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 5063 Operation the Sequence
- Operation the Sequence(HDU 5063)
- HDU 5063Operation the Sequence(暴力)
- hdu 5063 Operation the Sequence(思路)
- HDU - 5036 Operation the Sequence
- hdu5063——Operation the Sequence
- hdu 5063 Operation the Sequence(Bestcoder Round #13)
- HDU 5063 Operation the Sequence(暴力 数学)
- hdu 5063 Operation the Sequence (数学公式逆推)
- 【交互设计】新游戏如何推广才能赚到钱
- 成员变量和局部变量的区别
- Android 消息机制
- Cocos2d-x中__Array容器以及实例介绍
- 关于java的多线程
- hdu 5063——Operation the Sequence
- 额外企鹅去问的
- Effective C++ 读书笔记 条款33:避免遮掩继承而来的名称
- android基础--eclipse Junit的功能测试
- 【交互设计】新游戏如何推广才能赚到钱
- 小白linux学习[1]__安装篇
- 华为笔试题第三道
- C/C++中关于char是有符号还是无符号及其溢出问题
- 关于java数组的一点理解