摘要: D. GCD Counting 题意: 给出n个点的树,每个点有一个权值,找出一条最长的路径使得路径上所有的点的gcd>1 题解: gcd>1的一定不会有很多。所以暴力搞一下就行,不需要点分治。 1 #include <cstdio> 2 #include <algorithm> 3 #includ 阅读全文
posted @ 2019-02-16 17:43 蒟蒻LQL 阅读(175) 评论(0) 推荐(2) 编辑
摘要: B. Digital root 题意: 题目定义了x的digital root是S(x)。S(5)=5,S(38)=S(3+8=11)=S(1+1+2)=2. 有n个询问,每次询问给出ki和xi,要你求出digital root为xi的整数中,第k大的是什么。 题解: 观察可以发现,x的digita 阅读全文
posted @ 2019-02-16 17:28 蒟蒻LQL 阅读(187) 评论(0) 推荐(0) 编辑
摘要: B. Game with string 题意: 给出一个字符串s只包括小写字母。当轮到一个玩家的时候,他可以选择两个连续且相等的字母并且删除它。当一个玩家没得删的时候他就输了。 题解: 乍一看有点懵,像dp,但是观察一下就发现输赢和顺序无关,只跟能组成相同的对数量有关,这个数量是一定的。那么我们用栈 阅读全文
posted @ 2019-02-16 15:11 蒟蒻LQL 阅读(205) 评论(0) 推荐(0) 编辑
摘要: A. Integer Sequence Dividing 1 #include <cstdio> 2 3 using namespace std; 4 int n; 5 6 int main(){ 7 scanf("%d",&n); 8 if((n+1)%2==0){ 9 n=(n+1)/2; 10 阅读全文
posted @ 2019-02-16 13:04 蒟蒻LQL 阅读(259) 评论(0) 推荐(0) 编辑
摘要: A. Lunar New Year and Cross Counting 题解: 1 #include <cstdio> 2 3 using namespace std; 4 const int maxn=500+10; 5 const int dx[]={1,1,-1,-1}; 6 const i 阅读全文
posted @ 2019-02-16 12:19 蒟蒻LQL 阅读(213) 评论(0) 推荐(0) 编辑
摘要: B:Squares and Segments 题意: 给定n,求最小的a+b使得a*b>=n 题解: 直接开平方最优。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #include <iostream> 5 #i 阅读全文
posted @ 2019-02-16 10:28 蒟蒻LQL 阅读(249) 评论(0) 推荐(1) 编辑
摘要: C: 题意: 有n个整数ai,数列a有两个神奇的性质。1.所有的整数都在[l,r]范围内。2.这n个数的和能被3整除。现在给出l和r,和个数n,问你有多少种方法构造出数列a,方案数mod1e9+7. 题解: 一个数被3除只有三种可能。1.整除,2.余1,2.余2. 然后我们再想这个问题,[l,r]区 阅读全文
posted @ 2019-02-16 09:45 蒟蒻LQL 阅读(180) 评论(0) 推荐(0) 编辑