Hdu 5063 Operation the Sequence
来源:互联网 发布:2016交通安全事故数据 编辑:程序博客网 时间:2024/05/22 06:04
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5063
BestCoder 13 1002。。题解写的有点迟啊。。周末打来了三场篮球赛,累成狗。。- -。。不过是时候加大训练强度了。。不能这么懒散了。。
问题意思:
给你一个初始的数组 1 - n。(值对应下标)
4种操作:
1.奇位置放前面,偶位置放后面。
2.前后调换。
3.每个值平方。
4.询问某个位置的值。。最多50次询问。
这个最多50次询问就的该问题的突破点。。对于每个询问,我们可以逆推回去,直接求该位置的值。。时间复杂度最多50 * m。。
比赛的时候,注意到这个50次询问了。。我们应该想到这种做法。。但是,我们没有从这里作为突破口去想算法。可能这就是我们的不成熟吧。。
后来听了学长的想法。。20 +分钟没有写出来程序。这又暴露了我们的一大缺点。。只能说,我们还有很大的成长空间。。
Code:
#include <iostream>#include <algorithm>#include <cmath>#include <cstdio>#include <cstring>#include <string>using namespace std;#define INT long longconst int N = 1e5 + 5;const INT mod = 1000000007;int n, m, od[N], top = 0;void Init(){ top = 0;}int solve(int id){ int mid = (n + 1) / 2, cnt = 0; for(int i = top - 1; i >= 0; i --){ if(od[i] == 1){ if(id > mid) id = (id - mid) * 2; else id = id * 2 - 1; } if(od[i] == 2){ id = n + 1 - id; } if(od[i] == 3){ cnt ++; } } INT ans = id; for(int i = 1; i <= cnt ; i ++){ ans = ans * ans % mod; } return ans;}int main(){// freopen("1.txt", "r", stdin); int T; scanf("%d", &T); while(T --){ scanf("%d %d", &n, &m); Init(); char order[4]; int type; for(int i = 1; i <= m; i ++){ scanf("%s %d", order, &type); if(order[0] == 'O'){ od[top ++] = type; } else { printf("%d\n", solve(type)); } } } return 0;}
对于这场BC,我只能吐槽太坑。。1002 竟然有人直接把题目上的代码粘上去提交过的。。。无力吐槽。。1003 竟然2层for循环,给过的。。
出题人这是要坑死hdu啊。。。最后hack时间弄的了了收场。。 - -。。
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
- hdu 5063 Operation the Sequence(Bestcoder Round #13)
- HDU 5063 Operation the Sequence(暴力 数学)
- hdu 5063 Operation the Sequence (数学公式逆推)
- HDOJ 5063 Operation the Sequence
- 中国剩余定理 算法摘记
- oracle字符/字符串替换
- 阻塞队列
- eclipse中svn插件的安装与使用
- android app修改属性改变gsensor
- Hdu 5063 Operation the Sequence
- 游戏开发之A*算法学习及java实现
- sizeof(数组名)和sizeof(指针) .
- c/c++ 基础(二) 定义常量
- WPF--event、delegate、EventHandler、RoutedEventHandler的区别
- 我的iOS工程结构
- Cheat Engine Tutorial 闯关手记
- Android SDK安装时出错“android Failed to rename directory”的解决方法
- aotocomplete.js 处理返回后台传回的json格式的数据