POJ 3087 模拟+hash
来源:互联网 发布:网络调试助手使用说明 编辑:程序博客网 时间:2024/06/06 07:33
也可以用map来搞
样例推出来 就没啥问题了 (先读的是B 然后是A 被坑好久)
//By SiriusRen#include <cstdio>#include <iostream>#include <algorithm>using namespace std;#define mod 10000007int n,T,cases,rec,vis[10000007];char a[605],b[605],c[933],s[933];int main(){ scanf("%d",&T); for(cases=1;cases<=T;cases++){ int t=0;rec=0; scanf("%d",&n); for(int i=1;i<=n;i++)cin>>b[i]; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=2*n;i++)cin>>c[i],rec=(rec*128+c[i])%mod; while(++t){ int temp=0; for(int i=1;i<=n;i++){ s[i*2-1]=a[i],s[i*2]=b[i]; temp=(128*temp+s[i*2-1])%mod; temp=(128*temp+s[i*2])%mod; } if(temp==rec){printf("%d %d\n",cases,t);break;} else if(vis[temp]==cases){printf("%d -1\n",cases);break;} else vis[temp]=cases; for(int i=1;i<=n;i++)b[i]=s[i]; for(int i=1;i<=n;i++)a[i]=s[i+n]; } }}
0 0
- POJ 3087 模拟+hash
- poj 2003 Hire and Fire list+hash+模拟
- poj 3087 模拟
- poj 3087 模拟
- poj 3087 模拟题
- POJ 3087(模拟)
- poj 3087 (模拟)
- 【模拟】POJ 3087
- poj 3087 直接模拟
- poj 3087 水模拟
- HDU1144(模拟+hash)
- [模拟]Perfect Hash UVA188
- HDU5090模拟,hash
- POJ 2503 Babelfish(HASH)
- poj 1200 hash
- POJ 2002 hash 题目
- POJ 3320 hash
- poj 1840 简单hash。
- 简单申请列表状态数据处理 yii2
- 【进程通信】无名管道 and 有名管道
- Pick Several Elements From a Vector Randomly
- struts2 学习笔记
- Android_程序未处理异常的捕获与处理
- POJ 3087 模拟+hash
- 阿里面试回来,想和Java程序员谈一谈
- 【noip2015】【DP】子串
- Yii2 - 03视图(View)操作,以及Layout的使用
- 静态链表的实现
- item点击回调封装(改变带来Position的参数)
- lintcode Max Points on a Line
- 使用Loader加载本地图片
- Java学习提要——对象序列化