Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/problem/E Description Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at t…
题意:给你一个台球桌面,一个台球的初始位置和初始速度方向(只可能平行坐标轴或者与坐标轴成45度角),问你能否滚进桌子四个角落的洞里,如果能,滚进的是哪个洞. 如果速度方向平行坐标轴,只需分类讨论,看它是否在台球桌的边沿即可. 如果速度方向和坐标轴成45度,如下图 将整个过程展开, 设出射方向与当前所在桌面的两个边沿的距离分别为X,Y,则有方程X+pn=Y+qm,扩欧可求得解.然后再根据p.q的奇偶性即可确定滚进的是哪个洞(根据图中洞编号的翻折关系).…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwwAAAHwCAIAAACE0n9nAAAgAElEQVR4nOydfUBT1f/Hbw9202m0r8…
Codeforces Codeforces Round #484 (Div. 2) D. Shark 题目连接: http://codeforces.com/contest/982/problem/D Description For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and…
The equation Problem's Link Mean: 给你7个数,a,b,c,x1,x2,y1,y2.求满足a*x+b*y=-c的解x满足x1<=x<=x2,y满足y1<=y<=y2.求满足条件的解的个数. analyse: 做法是扩展欧几里德. 1.首先是欧几里德算法,欧几里德算法是用于求任意两个数的最大公约数(gcd(a,b)), 这个方法基于一个定理,gcd(a,b)=gcd(b,a % b)(a>b),%表示取模. 我们来证明上述定理,因为a>b,…
题目大意:已知a,b,c,求满足ax+by=c (x>=0,y>=0)的(x+y)最大值与最小值与解的个数. 直接exgcd,求出x,y分别为最小正整数的解,然后一算就出来啦 #include<cstdio> #include<iostream> #define ll long long using namespace std; ll a,b,c,x,y,d,bd,ad,X1,Y1,X2,Y2; ll Abs(ll x){ return x>=0?x:-x; }…
算法思想 我们想求得一组\(x,y\)使得 \(ax+by = \gcd(a,b)\) 根据 \(\gcd(a,b) = \gcd(b,a\bmod b)\) 如果我们现在有\(x',y'\) 使得 \(bx'+(a\bmod b)y' = \gcd(b,a\bmod b)\) 那么 \(ax+by = bx'+( a-\lfloor\frac a b\rfloor b)y'\) 移项之后 \(ax+by = ay'+b(x'-\lfloor\frac a b\rfloor y')\) 我们可以…
题目链接:http://codeforces.com/contest/982 A. Row time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output You're given a row with nn chairs. We call a seating of people "maximal" if the two follow…
原博主:https://blog.csdn.net/amovement/article/details/80358962 B. Bus of Characters time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In the Bus of Characters there are nn rows of seat, each h…
题目链接 题意:给你一棵树,让你尽可能删除多的边使得剩余所有的联通组件都是偶数大小. 思路:考虑dfs,从1出发,若当前节点的子节点和自己的数目是偶数,说明当前节点和父亲节点的边是可以删除的,答案+1,因为最开始的节点没有父节点,所以最后答案-1 #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mp make_pair #define pb push_back usi…