自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 问答 (1)
  • 收藏
  • 关注

原创 算法入门经典第二版 习题5-5 Compound Words Uva10391

1 利用每个单词的首字母与一个数字索引相对应的方式快速确定二分查找范围; 2 把每个单词分割成两个子串分别查找;#include <iostream>#include <string>#include <vector>using namespace std;vector<string> dict[26];bool BinarySea...

2018-07-24 13:31:47 177

原创 算法入门经典第二版 3-7 DNA Consensus String

因为这是个人的笔记所以记录一下自己解这题的过程首先一心想暴力枚举求解却没有注意到会超时所以写了一份递归代码如下#include <iostream>#include <cstdio>#include <cstring>using namespace std;char k[10] = "AGCT";char s[55][1005],s2[1005],s3[1005];int ham,m,n;

2017-12-01 15:20:32 231

原创 算法入门经典第二版 3-8 Repeating Decimals

诸位,可能是我写的题太少了,今天被输出错误折腾了半天。 本题输出要求number of digits in repeating cycle后有两个换行才能AC, 而不是两个输出之间隔一个空行。#include <stdio.h>int r[100000],n[100000];int main(){ int a,b,kase = 0; while(scanf("%d %d",&a

2017-11-29 12:38:40 193

原创 算法入门经典第二版 3-9 All in All

#include <stdio.h>#include <string.h>#define INF 100000char s1[INF],s2[INF];int main(){ while(scanf("%s %s",s1,s2) != EOF) { bool f = true; int t = 0; char *p = NULL; for(

2017-11-28 22:52:04 202

原创 算法入门经典第二版 3-5 Puzzle

1.提醒一下自己初始化很重要。2.因为自己在solve()中使用for(int i = 0; i < strlen(command); i++) 没注意到strlen(command)返回的是最长的命令输入的字符个数而不是当前字符个数导致无法ACeg:command 接收到”LLLRRRAAA”的输入 command为 “LLLRRRAAA”(末尾没有\0) 然后 command 接收到”BBB

2017-11-27 18:13:26 551

原创 算法入门经典第二版 3-4 Periodic Strings

首先题的两个连续的输出要用一个空行隔开,其次无循环周期的字符串被认为循环周期为字符个数,如qwer的循环周期为4#include <stdio.h>#include <string.h>int main(){ char s[85]; int T; scanf("%d",&T); while(T--) { scanf("%s",s);

2017-11-26 23:56:03 179

原创 算法入门经典第二版 3-3 Digit Counting

如果你使用的 Dev-C++,CodeBlocks等编译器默认不是支持C++11标准的 先更改编译器选项,更改成C++11标准,自行百度。#include <stdio.h>#include <string>#include <cstring>using namespace std;int main(){ int a[10],T,N;; string s; scanf

2017-11-26 14:22:01 410

原创 算法入门经典第二版 3-2 Molar Mass

#include <stdio.h>#include <string.h>#include <math.h>int num[100000];char s[100000];double m[] = {12.01,1.008,16.00,14.01},mass;int i,n;void countMass(){ int cnt = 0,t; memset(num,0,sizeo

2017-11-26 08:49:05 212

原创 算法入门经典第二版 3-1 Score

#include <stdio.h>#include <string.h>int main(){ int T; char s[85]; scanf("%d",&T); while(T--) { scanf("%s",s); int n = strlen(s),score = 0,subscore = 1; if(n <

2017-11-25 11:39:14 239

原创 算法竞赛入门经典第二版 2-6 permutation

#include <stdio.h>#include <string.h>using namespace std;int main(){ int count[10]; for(int i = 123;i <= 333;i++) { memset(count,0,sizeof(count)); bool f = true;

2017-11-19 14:51:51 244

原创 算法竞赛入门经典第二版 2-5 decimal

#include <iostream>#include <stdlib.h>using namespace std;int main(){ const int max = 1000000; int a, b, c; int count = 0; while (scanf_s("%d %d %d",&a,&b,&c) == 3 && a <= max && b <

2017-11-19 14:43:27 348

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除