HDU 1708

思路 :二位数组维护数目。

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<stdlib.h>
 4 #include<memory.h>
 5 #include<string.h>
 6 #include<algorithm>
 7 #include<cmath>
 8 #include<stack>
 9 const int MAXX= 50000;
10 const int mod=1e9+7;
11 using namespace std;
12 typedef long long ll;
13 int ans[51][27];
14 char str1[31],str2[31];
15 int k;
16 int n;
17 int main()
18 {
19       scanf("%d",&n);
20       while(n--)
21       {
22           memset(ans,0,sizeof(ans));
23           scanf("%s",str1);
24           scanf("%s",str2);
25           scanf("%d",&k);
26           int len1=strlen(str1);
27           int len2=strlen(str2);
28           for(int i=0;i<len1;i++)
29           {
30               ans[0][str1[i]-‘a‘]++;
31           }
32           for(int i=0;i<len2;i++)
33             ans[1][str2[i]-‘a‘]++;
34           for(int i=2;i<51;i++)
35             for(int j=0;j<26;j++)
36           {
37               ans[i][j]=ans[i-1][j]+ans[i-2][j];
38           }
39           for(int i=0;i<26;i++)
40           printf("%c:%d\n",‘a‘+i,ans[k][i]);
41           cout<<endl;
42      }
43 }
时间: 2024-10-05 03:00:34

HDU 1708的相关文章

HDU 1708 Fibonacci String(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1708 Problem Description After little Jim learned Fibonacci Number in the class , he was very interest in it. Now he is thinking about a new thing -- Fibonacci String . He defines : str[n] = str[n-1] + s

HDU 1708 简单dp问题 Fibonacci String

Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4568    Accepted Submission(s): 1540 Problem Description After little Jim learned Fibonacci Number in the class , he was very int

Fibonacci String(hdu 1708)

Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5008    Accepted Submission(s): 1690 Problem Description After little Jim learned Fibonacci Number in the class , he was very int

HDU 1708 Fibonacci String(斐波那契字串)

Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5358    Accepted Submission(s): 1819 Problem Description After little Jim learned Fibonacci Number in the class , he was very in

杭电 HDU ACM 1708 Fibonacci String

 Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4102    Accepted Submission(s): 1396 Problem Description After little Jim learned Fibonacci Number in the class , he was very

(HDU)1708 -- Shopaholic (购物狂)

题目链接:https://vjudge.net/problem/HDU-1708 刚开始写了一个呆萌模拟TLE蠢代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 7 using namespace std; 8 9 char ans[100000]; 10 char temp[

HDU分类

模拟题, 枚举 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 12

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

HDU——PKU题目分类

HDU 模拟题, 枚举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