当前位置:网站首页>Blue Bridge Cup_ Diophantine equation
Blue Bridge Cup_ Diophantine equation
2022-06-09 02:24:00 【This question AC sleep again】
a*x+b*y=c
d=gcd( a,b );
if( c%d==0 )
{
x=x0+b/d*n;
y=y0-a/d*n;
}01 Find the grid point between two points of a line segment
( y2-y1 )*x+( x1-x2 )*y=y2*x1-y1*x2;
a=y2-y1;
b=x1-x2;
c=y2*x1-y1*x2;
d=gcd( a,b );
x1 < x < x2
x1 < x1+b/d*n < x2
-d < n < 0
cnt=d-1;
02 pick Theorem s=j/2+k-1;
Cited example :
A closed polygon on a two-dimensional plane is given , The vertices of a polygon are all lattice points .
Please calculate the number of grid points on the polygon boundary j, Number of internal grid points k, And the area of the polygon s
03 extended euclidean algorithm _ Sum of special solutions gcd
typedef long long LL;
LL extend_gcd( LL a,LL b,LL& x,LL& y )
{
if( b==0 ) { x=1; y=0; return a; }
LL d=extend_gcd( b,a%b,y,x );
y-=a/b*x;
return d;
}
01
a*x0+b*y0=gcd(a,b) (1)
b*x1+(a%b)*y1=gcd(b,a%b) (2)
gcd(a,b)=gcd(b,a%b) (3)
(1)(2)(3) ==> a*x0+b*y0=b*x1+(a%b)*y1 (4)
(a%b)*y1=(a-a/b*b)*y1 (5)
(4)(5) ==> a*x0+b*y0=b*x1+(a-a/b*b)*y1
a*x0 b*y0
a*y1 b*x1+(-a/b*b)*y1
Contrast coefficient ==> x0=y1 y0=x1-(a/b)*y1
02
a*x+b*y=c
extend_gcd() ==> x0,y0,d
tt=c/d;
x=x0*tt+b/d*n;
y=y0*tt-a/d*n;
边栏推荐
猜你喜欢

Classify the audio and put it into the corresponding folder according to the file name

20、ADS使用记录之E类功放设计(上)

Blue Bridge Cup_ N-ary linear equations_ Gauss elimination

Read the log + regularize and extract the desired content + write the script to csv/xlsx

Redis集群搭建

Zhihu hot discussion: at the age of 35, do you want to escape Beijing, Shanghai and Guangzhou?

27 | discussion on high water level and leader epoch

技术负责人如何搞垮一个团队?

飞书要不要做生态?剖析第一家 All in 飞书的独立 SaaS 案例

价值600的抖音云蹦迪直播间项目,靠直播打赏收益的风口项目源码
随机推荐
Using redis in business code to achieve caching effect
S系列·删除文件夹的几种姿势
pkg-config --modversion opencvPackage opencv was not found in the pkg-config search path.Perhaps y
About database: vba+sql uses select * from a where name1 regexp to 'protect', and the error prompt is "operator missing"
CVE-2022-30525漏洞複現
Analyze several interview questions: = = and = = =; Binding events; regular expression
A problem of deserialization of primitive classes
Mysql database connection query join principle
Jericho's several descriptions on SPI host configuration parameters]
Blue Bridge Cup_ Multiple problem_ stack_ Remainder
(10.3)【隐写缓解】隐写防护、隐写干扰、隐写检测
Lvs+keepalived high availability
Blue Bridge Cup_ N-ary linear equations_ Gauss elimination
Create house with UE4 brush BSP
C#关于缓存区和数据流的问题
马上消费:打击征信修复不遗余力,乱象根治呼唤社会合力
力扣解法汇总1037-有效的回旋镖
[suctf 2018]multisql MySQL preprocessing
Exploration and best practice of automatic verification of object acquisition technology
【Azure 应用服务】NodeJS Express + MSAL 应用实现AAD登录并获取AccessToken -- cca.acquireTokenByCode(tokenRequest)