Codeforces 1114 F 题意:给你一个序列\(a_{1\dots n}\),以及\(q\)次查询,每次查询有两种格式: TOTIENT \(l\) \(r\):求出\(\phi(\Pi_{i=l}^ra_i)\). MULTIPLY \(l\) \(r\) \(x\):将从\(l\)到\(r\)的所有数乘上\(x\leq 300\). 处理每次查询. 思路:首先我们知道设\(x=\Pi_{i=1}^np_i^{e_i}\),则\(\phi(x)=x\Pi_{i=1}^n\frac{p…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array…
Codeforces 710 F 思路:KMP学的还是不过关啊... 按照字符串的长度分类,如果长度大于\(\sqrt{n}\)的就扔到什么地方等待查询,否则就扔进trie里面. 对于查询,我们先在trie树中暴力找有多少出现过的子串,因为trie中长度不超过\(\sqrt{n}\),那么这个操作总共不会超过\(n\sqrt{n}\)次. 然后对于每一个长度大于\(\sqrt{n}\)的,把kmp的fail数组构造出来,暴力在待查询串中查询出现次数.因为长度大于\(\sqrt{n}\)的不会超过…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
[题目链接]:http://codeforces.com/problemset/problem/797/E [题意] 给你一个n个元素的数组; 每个元素都在1..n之间; 然后给你q个询问; 每个询问由p和k构成; 会对p进行 p=p+a[p]+k操作若干次; 你要输出p第一次大于n之后操作了多少次; [题解] 部分DP; 这里对于k>400的询问; 我们直接暴力求解; 因为这时暴力所花费的时间已经可以接受了; 而对于剩余的k<=400的询问; 我们写一个记忆化搜索来求解; 很棒的思路吧 [N…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n …
time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard output This task is very simple. Given a string S of length n and q queries each query is on the format i j k which means sort the substring consisting…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output A function is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all . We'll…
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output A string t is called nice if a string "2017" occurs in t as a subsequence but a string "2016" doesn't occur in t as a subsequence…
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. I…