Line 【CodeForces - 7C 】

英飞凌AURIX™ Development Studio(ADS)工程调试与烧录实战指南 本文详细介绍了英飞凌AURIX™ Development Studio(ADS)的工程调试与烧录实战指南。从调试环境搭建、硬件连接到断点设置、变量监控等核心调试技巧,帮助开发者快速掌握ADS安装使用教程,提升多核处理器开发效率。 阅读详情

A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.

Input

The first line contains three integers A, B and C ( - 2·109 ≤ A, B, C ≤ 2·109) — corresponding coefficients of the line equation. It is guaranteed that A2 + B2 > 0.

Output

If the required point exists, output its coordinates, otherwise output -1.

Examples

Input

2 5 3

Output

6 -3

题意:

解二元一次方程,存在则输出该解,不存在则输出-1 。

 

将ax+by+c=0,

化为  ax+by = -c/gcd(a,b)*gcd(a,b)   ,套拓展欧几里得就可以解出了

代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

void gcd(long long a,long long b,long long& d,long long& x,long long& y)
{
	if(!b)
	{
		d=a;
		x=1;
		y=0;
	}
	else
	{
		gcd(b,a%b,d,y,x);
		y-=x*(a/b);
	}
}

int main()
{
	long long a,b,c,d,x,y;
	while(~scanf("%lld%lld%lld",&a,&b,&c))
	{
		gcd(a,b,d,x,y);
		if(c%d!=0)
			printf("-1\n");
		else
			printf("%lld %lld\n",-x*(c/d),-y*(c/d));
	}
	return 0;
}

 

ROS2通过ros2_socketcan实现CAN总线高效数据过滤与多节点通信 本文详细解析了ROS2通过ros2_socketcan实现CAN总线高效数据过滤与多节点通信的技术方案。文章重点探讨了CanFilterList的工作原理、多过滤器组合使用及动态配置策略,有效解决了工业应用中CAN总线数据过载问题,显著降低了CPU负载并提升了系统实时性。 阅读详情

相关推荐

从零构建锂电池主动均衡系统:Simulink仿真中的Buck-Boost拓扑实战指南

本文详细介绍了如何在Simulink中从零构建基于Buck-Boost拓扑的锂电池主动均衡系统。通过仿真环境搭建、参数优化、控制策略设计和性能评估,为工程师提供了完整的实战指南,帮助快速验证和优化均衡算法,提升电池组一致性与寿命。

gitlab7runner的博客 897

CodeForces 7C(扩展欧几里德解方程)

Description A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or t

MBLHQ的博客 690

Colmap中 patchmatch源码

惊世骇俗的Colmap PatchMatch源码 500多行,简明易懂 先了解PatchMatch的options: max_image_size: 任一维度的最大图像尺寸 gpu_index: gpu的下标 depth_min,depth_max: 随机采样的深度范围 window_radius:用于计算NCC(两图片的归一化互相关),NCC的计算需要用到 win_size. 图像匹配 | NCC 归一化互相关损失 | 代码 + 讲解 - 知乎 (zhihu.com) window_step: 用.

qq_24884193的博客 2210

G - Line CodeForces - 7C

A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out that s...

lihuanz的博客 227

STM32G030C8T6 ADC+DMA实战:同时采集外部电压和芯片温度的完整代码流程

本文详细介绍了STM32G030C8T6芯片通过ADC+DMA实现外部电压和芯片内部温度采集的完整流程。从硬件设计到CubeMX配置,再到驱动模块化实现与系统优化,提供了高精度多通道采集系统的实战指南,特别适合嵌入式开发者在工业控制和环境监测项目中应用。

weixin_42653691的博客 467

别再只调OpenCV参数了!手把手教你用Python bm3d库搞定图像去噪(附完整代码与效果对比)

本文详细介绍了BM3D算法在图像去噪中的高级应用,通过Python bm3d库实现超越OpenCV传统方法的去噪效果。文章包含完整代码示例、参数调优技巧及工程化应用场景,帮助开发者掌握这一被称为'传统方法天花板'的技术,显著提升图像信噪比和细节保留能力。

weixin_28362173的博客 366

Codeforces 7C Line(拓展欧几里得)

C. Line time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A line on the plane is described by an equation Ax +

hch丶 827

【虚幻引擎UE】UE5 可编辑动态样条线轨迹及AI跟随路径移动(含工程源码)

【虚幻引擎UE】可编辑动态样条线轨迹及AI跟随路径移动

灵境引路人 6227

Line CodeForces - 7C

点击打开链接 欧几里得算法参考https://www.cnblogs.com/hadilo/p/5914302.html 扩展欧几里得就是 求方程ax+by=c的最小整数解 1. c%gcd(a,b)!=0 则方程无解 2. c%gcd(a,b)==0 则有a*x+b*y==gcd(a,b)成立 因为gcd(a,b)==gcd(b,a%b) 所以b*x+(a%b)*y=...

sunyutian1998的博客 409

华为OD机试双机位C卷-AI面板识别(Py/Java/C/C++/Js/Go)

华为OD机试双机位C卷 AI面板识别,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解以及在线OJ模拟做题。华为OD机试 - AI面板识别。

qq_45776114的博客 1343

基于PCL的电力线点云提取与分割实现

本文基于PCL库实现电力线点云提取与分割,包含6个核心处理阶段:文件读取与结果文件夹创建、高程滤波分割候选点云、欧式聚类去噪、电力线分段提取、球形邻域搜索补全点云、最终分割与可视化保存。通过PCA计算点云线性特征(阈值0.91)筛选电力线点,采用欧式聚类(容忍度3.0)去除噪点,并针对不同规模聚类差异化设置球形搜索半径(4.0/6.0)补全点云。最终通过欧式聚类分割并可视化带颜色点云。算法对高程滤波阈值、聚类参数等具有敏感性,需根据点云特性调整优化。

weixin_45196569的博客 192

Codeforces 7C Line【扩展的欧几里得】

Discription A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to fin...

No Pain, No Gain . 412

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Codeforces Beta Round #7 C. Line

Codeforces Beta Round #7 C. Line 题目链接 A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out that such points do not

旺崽的博客 2609

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

CodeForces 7C Line

ax+by+c=0可以转化为ax+by=-c; 可以用扩展欧几里德算法来求ax1+by1=gcd(a,b)来求出x1,y1 此时gcd(a,b)不一定等于-c,假设-c=gcd(a,b)*z,可得z=-c/gcd(a,b); 则ax+by=-c <==> (ax1+by1)*z=gcd(a,b)z; <==> ax1*z...

deyou1988的专栏 164

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces 7C.Line

1 题目描述(题目链接) 2 题解   扩展欧几里得算法。 def ext_gcd(a, b): global x, y if not b: return a g = ext_gcd(b, a % b) x, y = y, x - a//b * y return g if __name__ == "__main__": co = input().split() A, B, C = int(co[0]), int(co[1]), i

qq_39378221的博客 256

codeforces 7C Line

题意:给条直线方程,Ax+By+C=0问是否存在整数x,y满足方程.存在任意输出,否则输出-1 思路;直接套欧几里得解出来。 #include #define ll long long using namespace std; void exgcd(ll a,ll b,ll &d,ll &x,ll &y) { if(!b) { x=1;y=0;d=a; } else { ex

chen_minghui的博客 445

Codeforces7 C.Line(exgcd)

题意: 给定A,B,C,表示有一条方程为Ax+By+C=0的直线。 问是否存在一个点(x,y),满足x和y都是整数,且在直线上。 如果无解输出-1,否则输出一组解。 数据范围:-2e9<=A,B,C<=2e9

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 266

Line codeforces7C

这道题相当于是一道扩展gcd的模板提。首先要知道什么是扩展gcd,按照目前的理解来说,扩展gcd是来求一组二元不定方程组的解,这个跟逆元有关,对任意的a,b和它俩的gcd(a,b),总能找到一组解使得ax+by=gcd(a,b),同时利用求gcd的方法我们知道,bx1+(a%b)y1=gcd(b,a%b),我们知道的是gcd(a,b)=gcd(b,a%b),所以将方程组化简就得到ax+by=bx1...

Mrzhq7的博客 364

Codeforces Beta Round #7 C. Line Exgcd

C. Line 题目连接: http://www.codeforces.com/contest/7/problem/C Description A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are i...

weixin_34205826的博客 127

CodeForces - 7C Line【扩展欧几里得】

【题目描述】 A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out...

inv0ker的博客 289

CodeForces 7C Line Exgcd(数论)

传送门:http://codeforces.com/problemset/problem/7/C 题意&&思路:找出方程一组通解,扩展欧几里得算法就是解方程(欧几里得算法详解) 先附上扩展欧几里得算法模板: ll gcd(ll a,ll b,ll& x,ll& y) { if(!b) { x=1; y=0; return a; } ll ans=gcd

GDUFE_SSS 680

CodeForces 7C - Line

扩展欧几里德算法问题。#include #include typedef long long ll; using namespace std; int extended_gcd(ll a,ll b,ll &x,ll &y) { if(b==0) { x=1; y=0; return a; } ll

菜鸟 565

Codeforces Beta Round 7 C. Line 题解 数论 扩展欧几里得

数论 扩展欧几里得 Codeforces题解 C++代码 附详细注释

一只摸鱼的bbc 641

CodeForces 7C Line Exgcd(数论)

题意:给直线AX+BY+C=0,找出直线上的一个整数点,没有则输出-1 思路:exgcd裸题...数论真是博大精深... #include using namespace std; void gcd(long long a,long long b,long long& d,long long& x,long long& y) { if(!b){d=a,x=1,y=0;}

围巾的ACM博客 497

20160321 CodeForces 7C Line(拓展欧几里得)

题意: 给你a,b,c,求在ax+by+c=0线段上的坐标为整数的点,没有输出-1. 思路: ax+by=-c符合拓展欧几里得的形式,模板走你,注意a或b为零的处理。 #include #include using namespace std; long long exgcd(long long a,long long b,long long &x,long long &y) {

WeRIndex 361
上一篇: FatMouse and Cheese 【HDU - 1078 】
下一篇: 统计难题【 HDU - 1251 】
Daisy's一乐景三
博客等级 码龄8年 2粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值