CF1146D Frog Jumping】的更多相关文章

CF1146D Frog Jumping 洛谷评测传送门 题目描述 A frog is initially at position 00 on the number line. The frog has two positive integers aa and bb . From a position kk , it can either jump to position k+ak+a or k-bk−b . Let f(x)f(x) be the number of distinct inte…
Frog Jumping 题目链接:http://codeforces.com/contest/1146/problem/D 数据范围:略. 题解: 首先发现,如果$x\ge a +b$,那么所有的$Num | gcd(a,b)$都可以取到. 这是显然的因为我们可以保证最右端点在$a+b$内. 那么我们只需要考虑小于$x$的部分. 可以暴力建边,跑出当前点需要的最右端点的最小值,用spfa或者堆优化dij都行. 代码: #include <bits/stdc++.h> #define N 10…
http://codeforces.com/contest/1077/problem/A A frog is currently at the point 00 on a coordinate axis OxOx. It jumps by the following algorithm: the first jump is aa units to the right, the second jump is bb units to the left, the third jump is aa un…
Content 在一个数轴上有一个动点,初始时在 \(0\) 这个位置上,接下来有若干次操作,对于第 \(i\) 次操作: 如果 \(i\) 是奇数,那么动点往右移 \(a\) 个单位. 如果 \(i\) 是偶数,那么动点往左移 \(b\) 个单位. 现在有 \(t\) 次询问,每次给定 \(a,b,k\) 三个数(其中 \(a,b\) 含义如上所述),求经过 \(k\) 次操作后动点所在的位置. 数据范围:\(1\leqslant t\leqslant 10^3,1\leqslant a,b,…
别问我为什么没有前三天,有时间再补~ 60+60+50=170. T1 . 坐等 memset0 ( 1s 256MB )( 原题:洛谷CF1151E Number of Components ) 树链剖分是个喜欢逛讨论区的女孩子.树链剖分看到有若干个小学生发的帖子,因为一些原因,这些帖子形成了一条链.其中第 i(1<=i< n)个帖子和第 i+1 个帖子用双向边相连树链剖分举报了这些帖子,然后作为管理员的 memset0,决定对帖子进行删除.其中第 i 个帖子有一个小学生值 a[i].但是,…
Forethought Future Cup - Elimination Round 窝也不知道这是个啥比赛QwQ A. Love "A" 给你一个串,你可以删去若干个元素,使得最后a的个数严格大于一半.求最大串长. #include<iostream> #include<cstdio> #include<cstring> using namespace std; char s[55];int v=0,n; int main() { scanf(&q…
A. Accommodation Plan 对于已知的$K$个点,离它们距离都不超过$L$的点在树上是一个连通块,考虑在每种方案对应的离$1$最近的点统计. 即对于每个点$x$,统计离它距离不超过$L$的点数$call[x]$,再减去离它和它父亲距离都不超过$L$的点数$cext[x]$,然后用组合数计算方案数. 对于$call[x]$可以通过点分治+排序双指针$O(n\log^2n)$统计. 对于$cext[x]$,注意到$cext[x]=call[x]-csub[x]$,其中$csub[x]…
A:Frog Jumping 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout); #define LL long long #define ULL unsigned LL #define fi first #define…
1146C Tree Diameter 题意 交互题.有一棵 \(n(n\le 100)\) 个点的树,你可以进行不超过 \(9\) 次询问,每次询问两个点集中两个不在同一点集的点的最大距离.求树的直径. 题解 和 GXOI2019旅行者 基本类似,二进制分组,对于每一位,编号当前位为 \(0\) 的分到一组,当前位为 \(1\) 的分到另一组.最大询问次数为 \(\log 100 = 7\) code #include<cstdio> int v1[105],v2[105]; int mai…
Description There are n lotus leaves floating like a ring on the lake, which are numbered 0, 1, ..., n-1 respectively. The leaf 0 and n-1 are adjacent. The frog king wants to play a jumping game. He stands at the leaf 0 initially. For each move, he j…