[acm]HDOJ 1200 To and Fro

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=1200

简单字符串处理,找规律


 1 /*
 2 11509672    2014-08-21 11:32:55    Accepted
 3 1200    0MS    380K    442 B    G++    空信高手
 4 */
 5 #include<iostream>
 6 #include<string>
 7 #include<cstdio>
 8 using namespace std;
 9 int main()
10 {
11     //freopen("input.txt","r",stdin);
12     string str;
13     int n,flag=1;
14     while(cin>>n && n!=0)
15     {
16         cin>>str;
17         int pnt;
18         for(int i=1;i<=n;i++)
19         {
20             flag=1;//重置左右
21             pnt=i;
22             while(pnt<=str.length())
23             {
24                 cout<<str[pnt-1];
25                 //左右分别讨论
26                 if(flag){pnt+=(2*n-2*i+1);flag=0;}
27                 else {pnt+=(2*i-1);flag=1;}
28             }
29         }
30         cout<<endl;
31     }
32     return 0;
33 }

[acm]HDOJ 1200 To and Fro

时间: 2024-10-07 08:02:45

[acm]HDOJ 1200 To and Fro的相关文章

hdu 1200 To and Fro(简单模拟或DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200 To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5129    Accepted Submission(s): 3550 Problem Description Mo and Larry have devised

[acm]HDOJ 2064 汉诺塔III

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2064 汉诺塔变种,只能从中间专业,递归关系为:f(n)=3*f(n-1)+2. 1 //汉诺塔变种,只能从中间转移 2 //11485816 2014-08-19 08:44:47 Accepted 2064 0MS 368K 307 B G++ 空信高手 3 #include<iostream> 4 #include<cstdio> 5 using namespace std; 6

[acm]HDOJ 2059 龟兔赛跑

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2059 起点和终点,共n+2个点,n+2个状态,简单DP即可. 1 //11512698 2014-08-21 17:11:55 Accepted 2059 2 //62MS 368K 969 B G++ 空信高手 3 //起点和终点,共n+2个点,n+2个状态,简单DP即可 4 #include<iostream> 5 #include<cstdio> 6 using namespa

[acm]HDOJ 3082 Simplify The Circuit

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3082 字符串处理+并联电阻公式 1 //11481261 2014-08-18 16:52:47 Accepted 3082 0MS 384K 733 B G++ 空信高手 2 #include<string> 3 #include<iostream> 4 #include<cstdio> 5 #include<cstdlib> 6 7 using names

[acm]HDOJ 2673 shǎ崽 OrOrOrOrz

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2673 拍两次序,交替输出 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 #define MAX_NUMBER 10000 6 bool myfunction1 (int i,int j) { return (i<j); } 7 bool m

HDU ACM 1200 To and Fro

解析:水题,直接模拟. 根据i可得出行为i/col.奇偶数行分别处理,奇数行列序为col-i%col-1,偶数行列序为i%col. #include<iostream> #include<set> #include<algorithm> using namespace std; int main() { char a[105][21]; char b[201]; int i,col,j,k; while(cin>>col && col) {

HDU 1200 To and Fro

To and Fro Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5493    Accepted Submission(s): 3799 Problem Description Mo and Larry have devised a way of encrypting messages. They first decide sec

acm hdoj 1157

Who's in the Middle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3136 Accepted Submission(s): 1171   Problem Description FJ is surveying his herd to find the most average cow. He wants to know

HDOJ ACM题目分类

模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 120