Cyclic Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 193    Accepted Submission(s): 125 Problem Description Count the number of cyclic permutations of length n with no continuous subsequence…
CSGO Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 459    Accepted Submission(s): 227 Problem Description You are playing CSGO.There are n Main Weapons and m Secondary Weapons in CSGO. You c…
Problem I. Count Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 42    Accepted Submission(s): 16 Problem Description Multiple query, for each n, you need to getn i-1∑ ∑ [gcd(i + j, i - j) = 1…
目录 题目链接 题意 思路 代码 题目链接 传送门 题意 求有多少个子区间满足\(a_l,a_{l+1},\dots,a_r\)均不相同且\(max(a_l,a_{l+1},\dots,a_r)-(r-l+1)\leq K\). 思路 听说是启发式分治然后就去学了下如何套板子,赛场上写搓了本地过不了样例,赛后改过来了. 启发式分治在本题的思路貌似就是在处理\([l,r]\)时找到区间最大值的位置\(mid\),然后看左半部分区间长度短还是右半部分短,然后暴力统计短的那部分的贡献. 首先预处理出以…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6701 题目大意为求满足 $max(a_{l},a_{l+1}\cdot \cdot \cdot a_{r})-(r-l+1)<=k$的区间个数. 先预处理出前缀最大值和后缀最大值和ST表,然后分治. 每次可以得到这次分治区间的区间最大值,然后我们要求出以该最大值为区间最大值时的合法区间数目. 这里我们可以枚举合法区间的左端点(右端点),然后通过化简上式得到合法的右端点(左端点),选择枚举左还是右端点…
以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之前的状态. 回退的时候,如果暴力点,就直接将每步所操作的线段树都存下来,然后直接翻阅回去,这种方法虽然简单,但是对空间和时间的需求太大了,肯定不能过. 所以这时候我们就可以选择可持久化操作. 可持久化是数据结构里面的一种方法,其总体就是把一个数据结构的历史状态全部都保存下来,从而能够快速的查找之前出…
#include<bits/stdc++.h>using namespace std;const int mod =1e9+7;int dp[1<<10];int cnt[1<<10];int ans[1<<10];char c[10];int t;void add(int &x,int y){    x=x+y>=mod?x+y-mod:x+y;}void del(int &x,int y){    x=x-y<0?x-y+mo…
题目:传送门. 这是一道阅读理解题,正解是DP,实际上模拟就能做.pij+1 指的是 (pij)+1不是 pi(j+1),判断能否交换输出即可. #include <iostream> #include <algorithm> #include <cstdio> #include<cstring> using namespace std; int t,n; ],str2[]; ]; int main(){ // freopen("cin.txt&q…
题目:传送门. 如果每个字符出现次数都是偶数, 那么答案显然就是所有数的和. 对于奇数部分, 显然需要把其他字符均匀分配给这写奇数字符. 随便计算下就好了. #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int main() { int T,n,a; scanf("%d",&T);…
题目:传送门. 题意:求题目中的公式的最大值,且满足题目中的三个条件. 题解:前两个数越大越好. #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int gcd(int a,int b) { if(!b) return a; return gcd(b,a%b); } int main() { int t; ci…
题目:传送门. #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int gcd(long long a,long long b) { if(!b) return a; return gcd(b,a%b); } ]; int main() { int T,n; scanf("%d",&…
题目:传送门. 题意:有n行,每行最多20个棋子,对于一个棋子来说,如果他右面没有棋子,可以移动到他右面:如果有棋子,就跳过这些棋子移动到后面的空格,不能移动的人输. 题解:状态压缩博弈,对于一行2^20-1种情况来说处理出每一种情况的后继状态,求出sg值,进行异或即可. #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std;…
躺了几天 终于记得来填坑了 1001 Ascending Rating   (hdoj 6319) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6319 单调队列 具体有点类似双端队列滑动窗口 题意:在一个队列中 每次都给定一个固定长度的区间 从i=1开始向后移动 每次在这个区间中进行a[i]和a[j]的比较 若a[i]<a[j] count++ 最大值更新为a[j] ,每个区间的最大值和count都分别异或i 求出分别的和 求区间最大值可以比较容易…
Sequence Problem Description Let us define a sequence as below f1=A f2=B fn=C*fn-2+D*fn-1+[p/n] Your job is simple, for each task, you should output Fn module 109+7.   Input The first line has only one integer T, indicates the number of tasks. Then,…
Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 474    Accepted Submission(s): 202 Problem Description Kazari has an array A length of L, she plans to generate an…
Problem Description Before the start of contest, there are n ICPC contestants waiting in a long queue. They are labeled by 1 to n from left to right. It can be easily found that the i-th contestant's QodeForces rating is ai.Little Q, the coach of Qua…
题目描述 In computer science, a character is a letter, a digit, a punctuation mark or some other similar symbol. Since computers can only process numbers, number codes are used to represent characters, which is known as character encoding. A character en…
题目描述 Let us define a sequence as belowYour job is simple, for each task, you should output Fn module 109+7. 输入 The first line has only one integer T, indicates the number of tasks.Then, for the next T lines, each line consists of 6 integers, A , B, C…
#include<bits/stdc++.h>using namespace std;int a[100010];char s[20];int zhiren[100010];vector<int>haoren[100010];int sum=0;void dfs(int x,int y,int flag){    if(x==y)        flag=1;//如果和被指认的人相同,则定为狼    sum+=flag;//并且后面直接或间接认为刚才那个是狼的人是好人的人也都是狼 …
//never use translation#include<bits/stdc++.h>using namespace std;int k;char a[20];//储存每个数的数值int times[20];//mn次数int timess[20];//mx次数int len;int mn;int mx;int kk,sum;void solve(){    kk=0,sum=0;    if(a[times[1]]==0)        return;    for(int i=1;i…
传送门 Kirinriki Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1012    Accepted Submission(s): 400 Problem Description We define the distance of two strings A and B with same length n isdisA,B=∑…
传送门 Classes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description The school set up three elective courses, assuming that these courses are A, B, C.…
传送门 Inversion Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Give an array A, the index starts from 1. Now we want to know Bi=maxi∤jAj , i≥2.…
Rikka with Competition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 445    Accepted Submission(s): 366 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situ…
Rikka with Subset Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1440    Accepted Submission(s): 721 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situatio…
Hard challenge Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 1487    Accepted Submission(s): 352 Problem Description There are n points on the plane, and the ith points has a value vali, an…
Kolakoski Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description This is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1--. This seque…
Euler theorem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb.…
Glad You Came Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1489    Accepted Submission(s): 629 Problem Description Steve has an integer array a of length n (1-based). He assigned all the e…
Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description Kazari remembered that she had an expression s…