题目分析: 这道题的难点在于要取模,而题面没有写. 容易想到一个O(1E7)的dp.KMP或者哈希得到相关位置然后对于相关位置判断上一个位置有多少种情况. 代码: #include<bits/stdc++.h> using namespace std; ; ; int n; string str; ][]; ]; ; struct hnum{ int base; unsigned ]; unsigned ]; }h[]; void read(){ ios::sync_with_stdio(fa…
题意 小豆参加了生物实验室.在实验室里,他主要研究蛋臼质.他现在研究的蛋臼质是由k个氨基酸按一定顺序构成的.每一个氨基酸都可能有a种碱基序 列si_j 构成.现在小豆有一个碱基串s,小豆想知道在这个碱基上都多少中不同的组合方式可能得到这个蛋白质.即求由k段字符串有序合并成的字符串s1,有多少种不同方式能够匹配字符串s,其中k段字符串的选法不同,或者与s匹配上的位置不同认为是不同的方式. \(1 ≤ k ≤ 100, |s| ≤ 10000,a_i ≤ 10\) 分析 参照scarlyw的题解.…
[BZOJ5337][TJOI2018]str(动态规划,哈希) 题面 BZOJ 洛谷 题解 就很呆... 显然按层\(dp\),如果能够匹配上就进行转移,直接哈希判断是否能够匹配就好了... #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define MOD 1000000007 #define MAX 10010 #define ull unsigned lon…
bzoj 5337 [TJOI2018] str Link Solution 水题 直接 \(f[i][j]\) 表示以第 \(i\) 位为结束位置,当前已经匹配了前 \(j\) 个氨基酸的方案数 使用哈希转移 转移复杂度 \(O(10)\),总复杂度 \(1e7\) Code #include<stdio.h> #include<cstring> #include<cstdlib> #include<algorithm> #include<vecto…
剑指 Offer 48. 最长不含重复字符的子字符串 Offer_48 题目详情 解法分析 解法一:动态规划+哈希表 package com.walegarrett.offer; /** * @Author WaleGarrett * @Date 2021/2/8 20:52 */ import java.util.HashMap; /** * 题目描述:请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度. */ public class Offer_48 { publ…
将Redis的常用操作封装了一下: import redis class MyRedis(): def __init__(self,ip,passwd,port=6379,db=0): #构造函数 try: self.r = redis.Redis(host=ip,password=passwd,port=port,db=db) except Exception as e: print('redis连接失败,错误信息%s' %e) def str_get(self,k): #获取数据要有返回值,…
Clairewd’s message Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10376    Accepted Submission(s): 3709 Problem Description Clairewd is a member of FBI. After several years concealing in BUPT,…
#字典dict------->唯一的映射类型 1.数据类型的划分 数据类型划分为可变数据类型和不可变数据类型. 不可变数据类型:tupe(元组).bool.int.str           可哈希 可变数据类型:list.dict.set(集合)                 不可哈希 dict(key,value)中: key必须是不可变数据类型 value可以是任意数据类型 2.dict的优点及特点 优点:用二分查找去查询.存储大量的关系型数据 特点:无序(3.5版本及之前的版本特点)…
3097: Hash Killer I Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 963  Solved: 364[Submit][Status][Discuss] Description 这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题: 给你一个长度为N的字符串S,求有多少个不同的长度为L的子串. 子串的定义是S[l].S[l + 1].... S[r]这样连续的一段. 两个字符串被认为是…
1.数组 public class Test{ public static void main(String args[]){ int[] intArray = new int[] {1,4,3,2,5};//等价于 : int intArray[] = new int[] {1,2,3,4,5}; System.out.println(intArray.length); //打印长度 //使用java.util.Arrays工具类 来操作 数组 System.out.println(java.…