poj2015-Permutation Code
来源:互联网 发布:c语言中memset函数 编辑:程序博客网 时间:2024/05/13 11:23
poj2015-Permutation Code
解题思路:这题如果仔细分析一下就会发现这是一道很水的模拟题,关键是找到该题的突破口。经过分析可以发现m[d]是一个突破口,然后其他的m[i]就可以一次推出来了。
注意一个数学公式:if a^b=c------>a=b^c
下面附上我的AC代码:
#include<stdio.h>#include<math.h>#include<string.h>#include<stdlib.h>int main(){ int x,i,j; while(~scanf("%d",&x)) { char s[35],p[35],c[70],m[70]; int splen,n,d; if(x==0) break; scanf("%s\n%s\n%s",s,p,c); splen=strlen(s); n=strlen(c); d=((int)(pow(n,1.5))+x)%n; for(i=0;i<splen;i++) if(c[d]==s[i]) m[d]=p[i]; int temp1,temp2;//分别记录c[i]在s中的位置,与m[(i+1)%n]在s中的位置 for(i=d-1;(i+n)%n!=d;i--) { if(i<0) i=(i+n)%n; for(j=0;j<splen;j++) if(c[i]==s[j]) { temp1=j; break; } for(j=0;j<splen;j++) if(m[(i+1)%n]==s[j]) { temp2=j; break; } m[i]=p[temp1^temp2];//运用题解中提到的公式 } for(j=0;j<n;j++) printf("%c",m[j]); printf("\n"); } return 0;}
- POJ2015 Permutation Code
- poj2015-Permutation Code
- POJ2015
- poj 2015 Permutation Code
- POJ 2015 Permutation Code
- poj Permutation Code (模拟)
- CODE 73: Permutation Sequence
- CODE 102: Next Permutation
- [leet code] Next Permutation
- poj2015--IP Address
- poj 2015 Permutation Code
- leetcode 日经贴,python code -Next Permutation
- leetcode 日经贴,Cpp code -Permutation Sequence
- 【Leet Code】31. Next Permutation---Medium
- LeetCode89/60 Gray Code/Permutation Sequence--迭代
- Permutation
- Permutation
- permutation
- Silverlight数据绑定
- unity3d 之 在Unity3D中使用静态变量
- Android 搭建开发环境之配置JDK和SDK
- Win7 EXE应用程序图标丢失的解决办法
- 【rzxt】Windows7 64位与32位两者之间到底有什么区别呢?
- poj2015-Permutation Code
- linux下安装netbeans, eclipse的IDE 的方法
- Java中的字符串分割函数
- hdu 2546(dp)
- poj3254 Corn Fields 状态压缩
- http_load测试工具
- 提取Google Play中的应用
- strlen和sizeof的区别
- python操作sqlite3