G. cocktail with snake 题意:给区间宽高:n,m,蛇形走位,问k步之后和原点的曼哈顿距离是多少 分析 int t = k / n 就是走k步后当行数 如果 t 是奇数,说明在往左走 如果 t 是偶数,说明在往右走 k % n 就是当前层往左往右走的步数 讨论一下,算出结果就行了 //------------------------
A - Bookshelf Filling 题意: 有a,b两种高度的书,a < b,a有n本,b有m本,全部竖着摆放在高度为h的书架上,现在要把至多(m - 1)本b书横着摆放在一些书的顶部。 问这样摆放之后的最小宽度是多少。 题解: 最简单的方法就是二分。这道题显然具有单调性,因为假设一个答案x可行,我们在中间抽出一本
传送门 赛时基本对了,结果被我推的错误数值表 hack 了队友,并且由于对多项式的操作不熟,导致最后一步一直没想出来 【大意】 给定 \(n, m\) ,求集合 \(\left\{ q | \left(\begin{matrix}1&2&3&\cdots&n\\p_1&p_2&p_3&\cdots&p_n\end{matrix}\right) ^ m = \left(\begin{matrix}1&2&
The 14th Jilin Provincial Collegiate Programming Contest 目录The 14th Jilin Provincial Collegiate Programming ContestProblem A. ChordProblem B. Problem Select题解代码Problem C. String Game题解代码Problem D. TrieProblem E. Shorten the Array题解代码Problem F. Q
比赛链接: https://codeforces.com/gym/102770 A. AD 2020 题目大意: 输入两个日期(日期范围是从 20000101 到 99991231),判断这两个日期及它们中间有多少个日期包含 202 这个子串。 思路: 预处理出每一个日期是否包含 202,然后做一个前缀和,询问的时候直接输出就行。 代码: #include <bits
创建测试表(有PrimaryKey,或者unique索引,如表id设置了自增时): CREATE TABLE citys( id INT(10) PRIMARY KEY AUTO_INCREMENT, city_name VARCHAR(255) UNIQUE, provincial VARCHAR(255) ); 插入测试数据 INSERT INTO citys(city_name,provincial) value('hangzh
1.6.3节中为什么要用这么多排序? 如图: 如果去掉【排序记录】,那么会报以下错误: 2.过滤记录中特别容易忽略的一点? 这个NOT表示,如果 Provincial字段不为NULL时,发送true数据给步骤空操作。 如果Provincial字段为NULL时,发送false数据给步骤空操作2
D. Fragmentation merging D. Fragmentation merging 题意:自己看 题解:对每一种情况进行判断,看是不是由最多两段组成就行了 AC代码 #include "bits/stdc++.h" using namespace std; #define ll long long const int maxn=5e3+10; const int inf=0x3f3f3f3f; inline int rd(){
A - Tasks dp或者贪心 #define x first #define y second #define pb push_back #define ls rt << 1 #define rs rt << 1 | 1 typedef long long ll ; const double esp = 1e-6 , pi = acos(-1) ; typedef pair<int , int> PII ; const int N = 1e6 + 10 , INF
题目描述 题目链接 题目大意 给你一个序列a[],以及q个查询。 对于每个查询,给出l,r,k,要求以a[l-r]作为b[]数组求出 dp[r-l+1][k]的值。 题目分析 通过分析题目给出的状态转移方程,我们可以发现: d p
const int N=1e5+5; int n,m,_; int i,j,k; int a[N]; struct Node { int l,r; int sz; ll sum; }t[N<<5]; int root[N],tot=0; vector<int> v; void update(int &x,int y,int l,int r,int po
F. Fair Distribution time limit per test1 second memory limit per test512 megabytes inputstandard input outputstandard output There are n robots and m energy bars in the Dream Kingdom. DreamGrid, the king, is trying to make a fair distribution of the ene
题意: clair的字符串中有几种子序列等于bob的字符串 思路: 自前向后遍历clair的字符串( i=1;i<=l1;i++) 自后向前遍历bob的字符串( j=l2;j>=1;j–) dp【j】代表clair前i个字符有dp【j】种子序列等于bob前j个字符 if(c[i]==b[j])dp[j]=(dp[j-1]+dp[j])%mod; ///c的第i位作为b的
A - A POJ - 1149 题意:m个猪圈,n个顾客,每个顾客有一些猪圈的钥匙,猪圈的猪可以相互交换,求最大卖出猪数。考虑猪圈的猪如果交换,实际上还是在顾客之间流动,所以以猪圈为单位建模并不合适,因此对于每一个猪圈,能访达所有的顾客都连一条边,因为猪圈的交换实际上还是在顾客之间流动,对于每
F - Instability 题意:一张图,求有多少个集合,包含三元环或者补三元环, 考虑 如下性质 Ramsey定理--世界上任意6个人中,总有3个人相互认识,或互相皆不认识。 当集合大小大于6时,发生了变化,一定满足,至少三个互不相连,或者互相连接, 记录一下6元以上的关系,算出组合数,然后暴力出 n = 5
A - A Count Task HDU - 6480 找出所有的区间只含一种字母。 注意long long #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const int N=1e6+5; int main(){ int t; scanf("%d",&t); while(t--){ st
Solved A B C D E F G H I J 5/11 AC AC AC AC AC ZOJ - 4104 - H 题意:给你一个序列,每次可以把一个元素移到最前面,问你移几次使得序列单增。 解法:偏思维, 做法比较多; 其实比较一下两个序列就好了; #include<bits/stdc++.h> using names
宁夏邀请赛的题,网络赛出锅之后来补了一下,还蛮有意思。题目地址:https://codeforces.com/gym/102222 A、给你一个栈和一堆pop、push操作,每次操作之后询问栈中的最大值,如果栈为空输出0 输入是给定的一个随机数生成器 每一次有元素进栈就把他与当前最大值比较,更新最大值之后把最大值压
题目:https://codeforces.com/gym/102222/problem/A Maximum Element In A Stack time limit per test10.0 s memory limit per test256 MB inputstandard input outputstandard output As an ACM-ICPC newbie, Aishah is learning data structures in computer science. S
Bahiyyah has a convex polygon with nn vertices P0,P1,⋯,Pn−1P0,P1,⋯,Pn−1 in the counterclockwise order. Two vertices with consecutive indexes are adjacent, and besides, P0P0 and Pn−1Pn−1 are adjacent. She also assigns a point QQ inside the pol
Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered 11 to nn ,the ii-th pile of stones has a_iai stones. There are n - 1n−1 bidirectional roads in total. For any two piles, there is a unique pat
题意 给你n(n≤109)n(n\leq 10^9)n(n≤109),m(m≤2×109)m(m\leq 2\times10^9)m(m≤2×109),p(p≤2×109)p(p\leq 2\times10^9 )p(p≤2×109),ppp为质数求 ∏i=1n∏j=1n∏k=1nmgcd(i,j)[k∣gcd(i,j)]\prod_{i=1}^n\prod_{j=1}^n\prod_{k=1}^nm^{gcd(i,j)[k|gcd(i,j)]}i=1∏n
BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the $j$-th column of the $i$-th row (indicated by $(i, j)$) contains an arrow (pointing either upwards, downwards, leftwards or rightwards) and an integer $a_
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=392 E:Sequence in the Pocket 思路:从后往前判断在不在应该在的位置,如果不在则需要放到最前面,通过cnt控制当前的数 比较 排好序的数组的数。 code: #include<bits/stdc++.h> using namespace std;#define LL
赛后总结: T:今天下午参加了答辩比赛,没有给予队友很大的帮助。远程做题的时候发现队友在H上遇到了挫折,然后我就和她们说我看H吧,她们就开始做了另外两道题。今天一人一道题。最后我们在研究一道dp的时候,被疯狂卡时间和内存,也是最后三十分钟开始写的,感觉受到了挫折。┭┮﹏┭┮