首页 > TAG信息列表 > Ayoub
C. Ayoub‘s function(思维+组合数学取补集)
https://codeforces.com/problemset/problem/1301/C 题意:给出一个字符串中1的个数,和它的长度,其余都是0,然后构造一个字符串,使得f(s)最大,f(s)表示有多少个点对,使得这个点对的区间中至少包含一个1。 思路:取反,考虑只有0串的情况,然后拿总数-只有0串的情况。 1有m个,那么0有n-m个。于codeforces 1301C Ayoub's function (排列组合)
Ayoub thinks that he is a very smart person, so he created a function f(s)f(s), where ss is a binary string (a string which contains only symbols "0" and "1"). The function f(s)f(s) is equal to the number of substrings in the string ssCF1105C 【Ayoub and Lost Array】
简单\(\text{dp}\) 我们设\(\text{dp[i][j]}\)表示前\(\text{i}\)位除以\(\text{3}\)的余数为\(\text{j}\)的个数,那么可以明显的推出状态转移方程 \(\text{dp[i][0]=dp[i-1][1]*mod[2]+dp[i-1][2]*mod[1]+dp[i-1][0]*mod[0]}\) \(\text{dp[i][1]=dp[i-1][0]*mod[1]+dp[i-1][1]*mod[C. Ayoub and Lost Array cf dp
C. Ayoub and Lost Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ayoub had an array aa of integers of size nn and this array had two interesting properties: All the integers in thC. Ayoub and Lost Array(DP)
(又是被队友带着上分的一场--) 题目链接:http://codeforces.com/contest/1105/problem/C 题目大意:给你n,l,r。每一个数都是在l,r范围之内,然后问你这n个数形成的序列能够被3整除。 具体思路:我们先计算出l,r区间内整除3之后是0的个数,是1的个数,是2的个数,然后我们从第一位循环到第n位,第i位之前