Description 题库链接 定义 \(F(x)\) 为 \(F(x-1)\) 与 \(F(x-2)\) 的连接(其中 \(F(0) = "0",F(1) = "1"\) ).给出一个长度为 \(n\) 的 \(01\) 字符串 \(s\) ,询问 \(s\) 在 \(F(x)\) 的所有子序列中出现了多少次. \(1\leq n\leq 100,0\leq x\leq 100\) Solution 首先 \(F(x)\) 是递归来定义的,显然我们可以递推来计算…
Description定义$F(x)$为$F(x−1)$与$F(x−2)$的连接(其中$F(0)="0"$,$F(1)="1"$)给出一个长度为$n$的$01$字符串$s$,询问$s$在$F(x)$的所有子序列中出现了多少次.$1≤n≤100$$0≤x≤100$ExamplesInput2 411Output14Input10 1001010101010Output553403224 $f[i][l][r]$表示有多少$F[i]$的子序列里包含字符串[l,r] 有3…
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…
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] + str[n-2] ( n > 1 ) He is so crazying that if someone g…
Fibonacci String Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5012 Accepted Submission(s): 1693 Problem Description After little Jim learned Fibonacci Number in the class , he was very interest…
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…
题目链接:http://codeforces.com/problemset/problem/797/C 题意: 给你一个非空字符串s,空字符串t和u.有两种操作:(1)把s的首字符取出并添加到t的末尾.(2)把t的尾字符取出并添加到u的末尾. 问你当经过一系列操作后,s和t均为空时,字典序最小的u. 题解: 操作的本质: s为队列,t为栈. 贪心思路: (1)找到s中的最小字符c,不断出队并加入t,直至有一次出队的字符等于c,停止出队. (2)当t的尾字符小于等于s中的最小字符时,优先弹出t的尾…
Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was…
C. Minimal string 题目链接:http://codeforces.com/problemset/problem/797/C time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya recieved a gift of a string s with length up to 105 characters fo…
/** 题目:F. String Compression 链接:http://codeforces.com/problemset/problem/825/F 题意:压缩字符串后求最小长度. 思路: dp[i]表示前i个字符需要的最小次数. dp[i] = min(dp[j]+w(j+1,i)); (0<=j<i); [j+1,i]如果存在循环节(自身不算),那么取最小的循环节x.w = digit((i-j)/x)+x; 否则w = i-j+1; 求一个区间最小循环节: 证明:http://w…
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qq574857122/article/details/34120269 题目链接:点击打开链接 题意: 给定一个数n 问把这个数拆成多个不同样的fibonacci数 有多少种拆法 #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<mat…
https://codeforces.com/problemset/problem/1117/E 就用abc表示数字来给每个数编码,编完直接问出移动的结果,反构造就行了,比C和D还简单. #include<bits/stdc++.h> using namespace std; #define ll long long int n; string s1,s2,s3; string t; string q1,q2,q3; ]; ]; void construct(){ ;i<n;i++){…
题目链接:http://codeforces.com/contest/828/problem/C 题解:有点意思的题目,可用优先队列解决一下具体看代码理解.或者用并查集或者用线段树都行. #include <iostream> #include <cstring> #include <queue> #include <vector> #include <cstdio> #include <map> #include <strin…
题目链接:http://codeforces.com/contest/779/problem/D 题意:给你一段操作序列,按顺序依次删掉字符串1中相应位置的字符,问你最多能按顺序删掉多少个字符,使得s2是剩下的字符构成的字符串的子列. 字符串长度为2e5每次查询的时间复杂度为n如果直接暴力那么复杂度就是n*n 如果二分一下答案的话复杂度就是n*logn再加上修改的复杂度总的复杂度是 (n+n)* logn #include <iostream> #include <cstring>…
Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... 考虑打表找规律(u1s1 这是一个非常有用的技巧,因为这个 \(10^{13}\) 给的就很灵性,用到类似的技巧的题目还有这个,通过对这些模数的循环节打表找出它们的共同性质,所以以后看到什么特殊的数据或者数据范围特别大但读入量 \(\mathcal O(1)\) 的题(比如 CF838D)可以考虑小数据打…
Friends and Subsequences 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/H Description Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on the…
http://www.codeforces.com/problemset/problem/494/B 题意:给出两个串S,T,求有几种将S分成若干个子串,满足T都是这若干个子串的子串. 思路:f[n]代表前n个字符来划分,有多少种划分方式,sum[i]代表1到i的f的和,转移就是:对于i这个位置,可以不选,因此首先 f[i]=f[i-1],然后若是选了i,那一定至少是在有匹配位置的左边开始匹配,假设L为小于i的最右边的匹配位置,则 F[i]+=ΣF[j] (1<=j<=L-1),然后也有可能自…
Sereja has a sequence that consists of n positive integers, a1, a2, ..., an. First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequence written on the squared paper, S…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF117G2.html 题目传送门 - CF177G2 题意 定义斐波那契字符串如下: $s_1="a"$ $s_2="b"$ $s_i=s_{i-1}+s_{i-2}\ \ \ \ \ (i\geq 3)$ 给定 $k,m$,以及对应的 $m$ 组询问. 每组询问一个字符串 $x$ ,问 $x$ 在 $s_k$ 中出现了多少次. $k\leq 10^{18},m\leq 10^…
Codeforces 710 F 思路:KMP学的还是不过关啊... 按照字符串的长度分类,如果长度大于\(\sqrt{n}\)的就扔到什么地方等待查询,否则就扔进trie里面. 对于查询,我们先在trie树中暴力找有多少出现过的子串,因为trie中长度不超过\(\sqrt{n}\),那么这个操作总共不会超过\(n\sqrt{n}\)次. 然后对于每一个长度大于\(\sqrt{n}\)的,把kmp的fail数组构造出来,暴力在待查询串中查询出现次数.因为长度大于\(\sqrt{n}\)的不会超过…
ou should process m queries over a set D of strings. Each query is one of three kinds: Add a string s to the set D. It is guaranteed that the string s was not added before. Delete a string s from the set D. It is guaranteed that the string s is in th…
D. String Mark time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexi…
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1. Given an array a consisting of n positive integers, find the number of its coprime subsequences.…
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely, he re…
C. String Transformation   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a string s consisting of |s| small english letters. In one move you can replace any character of thi…
Two people are playing a game with a string ss, consisting of lowercase latin letters. On a player's turn, he should choose two consecutive equal letters in the string and delete them. For example, if the string is equal to "xaax" than there is…
[题目链接]:http://codeforces.com/contest/803/problem/F [题意] 给你一个序列; 问你这个序列里面有多少个子列; 且这个子列里面的所有数字互质; [题解] 计算cnt[x]; 表示数组里有多少个数是x的倍数; 则某个子列里面所有的数字都能被x整除的子列个数为2cnt[x]−1 把这个值记为f[x]; 则我们用需要用容斥原理; 把所有能被2,3,..n整除的子列删除掉; 这里面会有重复计数的问题; 解决方式是,从大到小枚举f[x] 然后对于y=i*x的…
[题目链接]:http://codeforces.com/contest/779/problem/D [题意] 给你一段操作序列; 按顺序依次删掉字符串1中相应位置的字符; 问你最多能按顺序删掉多少个字符; 使得s2是剩下的字符构成的字符串的子列; [题解] 二分枚举能够按顺序删掉多少个字符m; 然后把1..m相应的字符标记成已经删掉了; 然后O(N)判断s2是不是剩下的字符的子串; 心态炸了. [完整代码] #include <bits/stdc++.h> using namespace s…
http://codeforces.com/problemset/problem/778/A 题意:给出字符串s和字符串p,还有n个位置,每一个位置代表删除s串中的第i个字符,问最多可以删除多少个字符使得s串依旧包含p串. 思路:想到二分,以为二分做法依旧很暴力.但是别人的做法确实就是二分暴力搞啊. 枚举删除字符数,然后判断的时候如果s串包含p串,那么可以往右区间找,否则左区间找. #include <bits/stdc++.h> using namespace std; #define N…
题目链接: https://codeforces.com/contest/1120/problem/C 题意: 从前往后压缩一段字符串 有两种操作: 1.对于单个字符,压缩它花费$a$ 2.对于末尾一段字符串,如果这段字符串是已经压缩过字符串的子串,那么可以选择压缩它,花费为$b$ 数据范围: $1\leq |S| \leq 5000$ $1\leq a \leq 5000$ $1\leq b \leq 5000$ 分析: 这道题目我们需要解决一个问题,计算某个子串出现的最早位置 转移,如果这个…