UVA11889 Benefit (数论)

BepInEx插件开发实战:用Visual Studio快速创建你的第一个Unity Mod(2024新版) 本文是2024年新版BepInEx插件开发实战指南,详细讲解如何使用Visual Studio快速创建你的第一个Unity Mod。内容涵盖专业开发环境搭建、插件生命周期解析、利用HarmonyX进行游戏代码注入、实现实时调试与热重载技巧,以及项目配置与打包发布全流程,助你从Mod使用者转变为创造者。 阅读详情


 

题意

给一个A一个C,求最小的B,

满足A和B的最小公倍数是C。

思路来源

自己的脑洞

题解

AC了之后看了看网上的题解

感觉比较沙雕

还是自己总结一发吧

先令B=C/A,注意到C=A*B/gcd(A,B)

如果gcd(A,B)=1,那么B显然即为所求,

如果gcd(A,B)不为1,不断地,令A/=gcd(A,B),再去令B=C/A,

判断A和B是否互质,互质输出B即可。

代码

#include <iostream>
#include <algorithm> 
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
const int INF=0x3f3f3f3f;
const int maxn=1e4; 
const int mod=1e9+7;
const int MOD=998244353;
const double eps=1e-7;
typedef long long ll;
#define vi vector<int> 
#define si set<int>
#define pii pair<int,int> 
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define lowbit(x) (x&(-x))
#define sci(x) scanf("%d",&(x))
#define scll(x) scanf("%lld",&(x))
#define sclf(x) scanf("%lf",&(x))
#define pri(x) printf("%d",(x))
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
#define mem(a,b) memset(a,b,sizeof(a)) 
using namespace std;
ll gcd(ll a,ll b)
{
	return b?gcd(b,a%b):a;
}
int main()
{
	int t;
	sci(t);
	while(t--)	
	{
		int a,b,c,d;
		sci(a),sci(b);
		if(b%a)
		{
			puts("NO SOLUTION");
			continue;
		}
		c=b/a;
		while((d=gcd(a,c))!=1)
		{
			a/=d;
			c*=d;
		}
		printf("%d\n",c);
	}
	return 0;
} 

 

ssd训练自己的数据集 基于SSD实现目标检测(训练自己的数据集) 阅读详情

相关推荐

小红书分享链接失效?教你永久保存笔记的2种方法(含API调用技巧)

本文详细解析了小红书笔记链接失效的原因,并提供了两种永久保存笔记的方法,包括短链接转换API调用技巧和本地归档技术。通过Python代码示例和工具推荐,帮助用户实现笔记内容的高效保存和管理,确保珍贵内容不再丢失。

gin88的博客 2748

uva11889(GCD,LCM)

题意: LCM(A,B) = C; 已知A,C,求最小的B; 思路: 设X为GCD(A,B); 那么C = A * B / X; 所以我们先C/A 然后通过乘以公约数,乘回来: #include #include #include using namespace std; int A, B, C; int main() { int t; scanf("%d

潜水的程序猿 531

数字逻辑EduCoder课设项目 厨房计时器系统设计 Logisim实现

数字逻辑EduCoder课设项目 厨房计时器系统设计 Logisim实现

weixin_51693702的博客 1万+

UVa 11889 - Benefit

b一定为c/a的倍数,lcm=a*b/gcd,lcm*gcd=a*b。然后枚举。 PS:一开始忽略了相乘会爆掉int这个问题。。WA了两次。。 #include #include using namespace std; int gcd(int a,int b) { return (b?gcd(b,a%b):a); } int main(){ int n; cin>>n

wcr1996的专栏 1642

LLM and Embedding区别

LLM(大语言模型)和 Embedding(嵌入)是自然语言处理(NLP)中的两个核心概念,它们的核心区别在于。Embedding 计算向量。

u010674101的专栏 1873

航天仿真必看:如何用SOFA库实现高精度GCRS-ITRS坐标转换?避坑指南

本文深入解析了航天仿真中高精度GCRS-ITRS坐标转换的关键技术,重点介绍了SOFA库在天球系与轨道系转换中的权威应用。通过对比传统方法的误差来源,详细阐述了SOFA库的转换算法优势、工程实现步骤及误差控制策略,为航天器轨道仿真提供毫米级精度的解决方案。

7h6j5k4l3的博客 850

UVa 11889 最小公倍数

vjudge

772

用Python实现四叉树(quad tree)

import numpy as np #正方形类 class square: #lx、ly为左上角坐标(x对应行号,y对应列号),rx、ry为右下角坐标 def __init__(self,lx,ly,rx,ry): self.lx=lx self.ly=ly self.rx=rx self.ry=ry #检查该矩阵中是否满足条件 #参数:原矩阵,阈值 #返回值:布尔类型 def check(s

weixin_44164489的博客 5868

uva11889

#include using namespace std; int d[10000001]={1,1,0},e[10000000]; int main(int argc, char *argv[]) {  int a,c,b,s,m=0,n,i,j,t;  /*for(i=2;i     for(j=2;j*i     d[j*i]=1;  for(i=0;i  if(!d[

chenlang888的专栏 647

普通开普勒式望远镜光学设计1-初始结构设计选型与物镜像差校正

普通开普勒式望远镜光学设计1: 完成了望远镜的总体结构设计,确定其物镜与目镜的初始结构选型,使用Zemax软件完成望远镜的双胶合物镜的像差校正。

faust_cao的博客 1万+

YOLOv11的物理信息神经网络(PINN):引入物理规律约束目标运动预测

本文介绍了YOLOv11目标检测与PINN物理信息神经网络的融合技术。YOLOv11采用增强特征提取和参数优化架构,在保持实时性的同时提升检测精度。PINN通过将物理方程嵌入损失函数,实现数据高效学习。两者的结合可显著提升运动预测准确性和遮挡处理鲁棒性。文章详细阐述了环境配置、YOLOv11模型验证方法,并提供了基础PINN框架代码实现,展示了物理约束如何通过自动微分整合到神经网络中。该融合技术适用于自动驾驶、无人机导航等需要物理规律建模的视觉感知场景。

本博客聚焦 YOLOv11 全流程落地,涵盖架构优化、数据集处理、训练技巧与多场景部署,兼及国产数据库、Java 开发与 AI 模型应用,内容兼顾理论与工程实践,为开发者提供系统干货,助力高效提升技术能力。 422

UVa 11889 Benefit (数论)

UVa 11889 Benefit题目大意:给两个整数A和C,求最小的整数B使得lcm(A,B)=C.若无解,输出”NO SOLUTION”(不含引号).题目分析:显然可知,若C%A!=0,则无解. 对于有解的情况,如下 设A=g∗p1B=g∗p2C=g∗p1∗p2A=g*p_1\\B=g*p_2\\C=g*p_1*p_2 要使lcm(A,B)=Clcm(A,B)=C,则p1与p2p_1与p_

Continue 651

YOLOv8与UNetV2融合:一种面向目标检测与图像分割的混合方法【附核心代码】

我们提出了一种基于YOLOv8和UNetV2相结合的混合架构。该架构利用YOLOv8作为主干进行目标检测,同时在YOLOv8的特征提取过程中,引入UNetV2来进行图像分割任务的增强。在该架构中,YOLOv8负责大范围目标检测和位置预测,而UNetV2则在检测网络的特征图基础上,通过其高效的上下文信息提取和细节恢复能力,进一步优化分割任务。在本文中,我们提出了一种改进YOLOv8的方法,通过引入图像分割网络UNetV2来提高图像分割检测性能。

一键难忘的博客 3524

uva11889 - Benefit 数论

Benefit  Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, hewho never has appropriate changes, asks for B Tomans such that lowest common multip

1356

深度学习工具包 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")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

uva 11889 - Benefit(数论)

题目链接:uva 11889 - Benefit

不慌不忙、不急不躁 1018

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

[UVa 11889] Benefit (基础数论+GCD+LCM)

UVa - 11889 已知 A,C,求最小的 B使得 LCM(A, B) = C 首先如果 A不能整除 C,则无解 由 lcm(A,B)=C=A∗Bgcd(A,B)lcm(A,B)=C = \frac {A*B} {gcd(A, B)} 得 CA=Bgcd(A,B)\frac C A = \frac B {gcd(A,B)} 设 gcd(A,B)=Dgcd(A,B)=D,A=A′∗D

MisDeer's blog 538

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

UVA 11889 - Benefit(数论)

题目链接:11889 - Benefit

Remilia's 989

UVa 11889 - Benefit (数论)

Benefit  Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, he who never has appropriate changes, asks for B Tomans such that lowest common mul

zhaosdfa 627

Benefit---UVA11889最小公倍数(两种方法)

UVA - 11889 题目链接:https://vjudge.net/contest/321024#problem/B Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, he who never has appropriate change...

孤风的博客 469

UVA11889 Benefit

lcm(A,B)=C 已知A和C求B,已知lcm=A*B/GCD  先将C除于A发现对于B而言我们多除了一个GCD 然后就求出多除的因子,然后乘回去就可以了   Benefit  Recently Yaghoub is playing a new trick to sell some more. When somebody giv

1327

UVA 11889 Benefit

题目链接点这儿

御坂美琴o((≧▽≦o) 977

UVa11889 Benefit

我还是很想了一会儿,大概有20min

QWsin的博客 784

[Uva 11889] Benefit

题目描述 给定两个正整数\(A和C\),若存在\(B\),满足\(lcm(A,B)=C\),则输出满足条件的最小的\(B\),若不存在,则输出NO SOLUTION。 分段得分、强化数据版本在此处:强化版题目,这里无解输出\(-1\)。 题目解答 无解情况 首先分析不存在的情况,既然\(C\)是最小公倍数了,是倍数,那么必定有\(A|C\),所以首先判断\(CmodA\),无解情况就弄完...

GKX328131442的博客 238

AMD Ryzen 3 3200G APU性能实测:集成显卡能否满足日常与游戏需求?

集成显卡作为现代处理器的重要组件,通过共享系统内存实现图形处理功能。其工作原理是将GPU核心与CPU集成在同一芯片上,有效降低系统成本和功耗。在入门级计算领域,集成显卡的技术价值在于为预算有限的用户提供完整的计算体验。以AMD Ryzen 3 3200G搭载的Radeon Vega 8为例,这款APU在办公应用、4K视频播放和轻度游戏等场景表现突出。通过CPU-Z和Cinebench测试可见,其四核心设计在多媒体处理和日常多任务中保持稳定性能。结合双通道内存配置优化,Vega 8显卡在《英雄联盟》等电竞游戏

aoe41606的博客 374

UVA 11889 Benefit

Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, he who never has appropriate changes, asks for B Tomans such that lowest common multiple of A and B e

colorfulshark 826

uva 11889 Benefit

Benefit Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, he who never has appropriate changes, asks for B Tomans such that lowest common multiple of A an

yu_ming_cong的专栏 603
上一篇: 蓝桥杯 21位花数
下一篇: UVA-10780 Again Prime? No Time. (数论-勒让德定理-质因数分解)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小衣同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值