ZOJ 1003 Crashing Balloon

ZOJ-1003-Crashing-Balloon 题目描述 On every June 1st, the Children’s Day, there will be a game named “crashing balloon” on TV. The rule is very simple. On the ground there are 100 labeled balloons, with the numbers 1 to 100. After the referee shouts “Let’s go!” the two players, who 阅读详情

题意:对于给定的两个数字,如果对于任意两个数字在1−100的范围内的分解因子(每个数字只能用一次)均有相同的因子,则输出大的数字,反之输出小的。

思路:dfs,将每个数字的所有分解方法存起来,然后直接暴力判断是否存在一种没有任何重复的因子。

#include <cstdio>
#include <string>
#include<iostream>
#include<vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdlib>
#include<string.h>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int>pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef vector<vector<ll> >vvi;
typedef vector<ll> vi;

//int  main()
//{
//  freopen("1.in", "w", stdout);
//  srand(time(NULL));
//  for (int i = 0; i < 10000; i++)
//  {
//      cout << rand() << " " << rand() << endl;
//  }
//}

//int main()
//{
//  freopen("1.in", "r", stdin);
//  freopen("11.in", "w", stdout);
//  int x, y;
//  int cot = 1;
//  while (cin >> x >> y)
//  {
//      cout << cot++ << " " << x << " " << y << endl;
//  }
//}

const int MAXN = 300000 + 10;
vvi a, b;
vector<ll>tmp;
void gao(ll x, ll st, vi &v, int t)
{
    v.push_back(st);
    x /= st;
    if (x == 1)
    {
        if (t == 0)a.push_back(v);
        else b.push_back(v);
        v.pop_back();
        return;
    }
    for (ll i = st + 1; i <= 100; i++)
    if (x%i == 0)gao(x, i, v, t);
    v.pop_back();
}


int main()
{
    ll x, y;

    ll kk = 1;
    //cout << kk << endl;
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    int cot = 1;
    while (scanf("%lld%lld", &x, &y) != EOF)
    {
        a.clear();
        b.clear();
        if (x < y)swap(x, y);
        for (ll i = 2; i <= 100; i++)
        {

            tmp.clear();
            if (x%i == 0)gao(x, i, tmp, 0);
            tmp.clear();
            if (y%i == 0)gao(y, i, tmp, 1);
        }
        if (y == 1)
        {
            vector<ll>v;
            v.push_back(1);
            b.push_back(v);
        }
        if (b.size())
        {
            int flag = 1;
            for (int i = 0; i < a.size(); i++)for (int j = 0; j < b.size(); j++)
            {
                set<ll>tmp;
                for (int k = 0; k < a[i].size(); k++)tmp.insert(a[i][k]);
                for (int k = 0; k < b[j].size(); k++)tmp.insert(b[j][k]);
                if (a[i].size() + b[j].size() == tmp.size())
                {
                    flag = 0;
                    goto loop;
                }
            }
        loop:;
            printf("%lld\n", flag ? y : x);
        }
        else
        {
            printf("%lld\n", x);
        }
    }
}
硬件设计--DC/DC电源芯片详解 本文参考:http://www.elecfans.com/article/83/116/2018/20180207631874.html https://blog.csdn.net/wangdapao12138/article/details/79763343 第一次写博客,不喜勿喷,谢谢!!! DC/DC电源指直流转换为直流的电源,从这个定义上看,LDO(低压差线性稳压器)芯片也应该属于D... 阅读详情

相关推荐

QDMA工程搭建/windows驱动编译与性能测试

请注意,根据您的目标操作系统,您可能需要在windows启动配置中启用测试签名的驱动程序,以便启用此驱动程序的安装。右键单击设备,选择更新驱动程序软件,然后选择构建的QDMA驱动程序的文件夹(通常为。创建一个新工程,在IP Catalog中搜索QDMA,双击创建qdma ip核。驱动程序安装安装驱动程序最简单的方法是通过Windows的“设备管理器”。如果系统提示未经验证的驱动程序发布者,请选择无论如何安装此驱动程序软件。本节主要介绍QDMA驱动在Windows系统的源文件、编译和安装过程。

qq_28455081的博客 2295

zoj 1003 Crashing Balloon

模拟。。 因子分解,判断是否有公共的因子。如果有的话,分数低的那个就是赢家;如果没有,分数高的就是赢家。气球一共100个,将得分与数字2-100逐个整出,如果是分解的因子就知道是踩了那哪些气球。 #include #include #include #include #include using namespace std; int f1,f2; void solve(

不努力,徒伤悲哇 512

大疆航线文件解析指南:5分钟搞懂KMZ里的template.kml和waylines.wpml区别

本文深入解析大疆无人机航线文件KMZ中template.kml与waylines.wpml的核心区别。template.kml是定义任务框架和全局参数的可编辑模板,而waylines.wpml是包含精确执行指令的最终文件。理解两者差异对于高效规划航线、批量生成任务及进行二次开发至关重要。

sun99的博客 875

浙江大学ZOJ 1003题 详解

1003题,同样因为英语不好,艰苦卓绝的翻译之后还是能大概读懂题意,前面说了一大堆介绍踩气球游戏的背景,也基本没啥用。。。 大概意思就是说有一百个气球,两个人A,B一开始都有1分,裁判员一喊开始,两个参赛选手就冲出去踩气球,最后他们的分数就是自己踩破的气球的数字的乘积,比如 343分和49分,但是会有一种情况就是49的人只能踩破49分的气球,但是343分的人要达到这个分数也必须踩破49的气球,所有就

qq_33771258的博客 1902

SAP SD核心流程解析:从销售订单到财务结算的实战指南

本文深入解析SAP SD模块从销售订单到财务结算的核心流程,重点剖析了销售订单中的行项目类别如何作为流程的“总开关”,决定了后续交货、开票及财务集成的走向。文章结合实战案例,详细拆解了正常销售、退货、第三方销售、寄售等典型流程的配置要点与国内化适配方案,并阐述了SD与财务模块集成的关键连接点,为顾问和用户提供了一份全面的实战指南。

weixin_29250403的博客 433

别再死记硬背了!用Multisim仿真5分钟搞懂运放电压跟随器到底要不要加反馈电阻

本文通过Multisim仿真实验,深入解析运放电压跟随器中反馈电阻的必要性。实验对比不同阻值对电路性能的影响,揭示反馈电阻在提供偏置电流通路、提升高频稳定性和ESD保护中的关键作用,并给出工程实践中的优化建议,帮助工程师快速掌握运放电路设计要点。

weixin_42641998的博客 379

ZOJ 1003 Crashing Ballon 解题思路

原题目内容 Crashing Balloon Time Limit: 2000 msMemory Limit: 65536 KB On every June 1st, the Children’s Day, there will be a game named “crashing balloon” on TV. The rule is very simple. On the ground t...

weixin_44517200的博客 477

【漏洞复现】用友NC-Cloud-反序列化-ResourceManagerServlet

NC Cloud是用友公司推出的大型企业数字化平台。支持公有云、混合云、专属云的灵活部署模式。NC Cloud完全基于云原生架构,技术先进、性能稳定、自主安全可控,支撑大中型以及超大型集团企业N层多site混合云部署方案,支持整个系统高可用、弹性扩展、双/多活,以及快速灾备恢复能力等。用友-NC-Cloud ResourceManagerServlet 接口存在反序列化漏洞,使得攻击者可以通过构造特定的请求远程执行恶意代码。此漏洞可能导致攻击者获取系统权限、执行任意命令,严重威胁系统的机密性和完整性。

漏洞复现 1373

浙大ZOJ 1003 Crashing Ballon问题解决及其他人的做法

完成了在ZOJ上的处女题,小兴奋,在此记录一下: 一、工程代码加上算法设计注释 --------------------------------------------------crash_ballon.h---------------------------------------------- #ifndef JLU_CCST_GDC_CRASH_BALLON_H #define J

xiaogugood的专栏 3666

Codex 100个真实案例 - 用AI生成建筑平面图SVG(室内设计师的新武器)

本案例用 Codex 生成一套完整的 Python 脚本,自动绘制 SVG 格式的建筑平面图。我们会设计一个90平两室一厅的户型——客厅、主卧、次卧、厨房、卫生间一应俱全,还会自动摆放家具(沙发、床、餐桌、橱柜)、标注尺寸和面积、绘制水电路走向、生成多种配色方案。最终输出的 SVG 文件可以直接用浏览器打开展示,也可以转成 PNG 交给客户。室内设计师看了都说好!

yueyeguzhuo的专栏 797

[网络安全自学篇] 六.OllyDbg动态分析工具基础用法及Crakeme逆向破解

这是作者的系列网络安全自学教程,主要是关于网安工具和实践操作的在线笔记,特分享出来与博友共勉,希望您们喜欢,一起进步。上一篇文章分享了IDA Pro反汇编工具的基础用法,并简单讲解一个EXE逆向工程解密实战方法;本篇文章将讲解动态分析OllyDbg工具的基础用法,主要是结合两个Crakeme案例逆向破解。希望对初学者有帮助,大神请飘过,谢谢各位看官!

杨秀璋的专栏 1万+

ZOJ Problem Set - 1003Crashing Balloon

Crashing BalloonTime Limit: 1 Second      Memory Limit: 32768 KB On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground ...

weixin_34384557的博客 221

三维重建(十八)——colmap的使用(粗浅)

三维重建(十八)——colmap的使用(粗浅)

河海大学研究生在读的学习笔记 1381

[ZOJ] 1003 Crashing Balloon

/*-----------------------------------------  zoj1003 Crashing Balloon  road 2007/08/31     dfs     --------------------------------------------*/#include #include #define SWAP(x,y) do { x = x^y; y =

roadtang的专栏 1000

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

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

zoj1003 Crashing Balloon

//zoj1003 Crashing Balloon //Accepted 1003 C++ 00:00.06 440K #include #include using namespace std; i

fairylan的专栏 1411

假人有限元模型

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

ZOJ1003 Crashing Balloon

Time Limit: 2 Seconds Memory Limit: 65536 KBOn every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled

松子茶的专栏 4477

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

ZOJ:1003 Crashing Balloon(DFS)

On every June 1st, the Children’s Day, there will be a game named “crashing balloon” on TV. The rule is very simple. On the ground there are 100 labeled balloons, with the numbers 1 to 100. After the referee shouts “Let’s go!” the two players, who each

Rrrrya 392

Crashing Balloon ZOJ1003

每年6月1日儿童节,电视上都会播放一个名为“撞气球”的游戏。规则非常简单。地面上有 100 个贴有标签的气球,编号为 1 到 100。在裁判喊道“我们走吧!”之后。两个玩家,每人都以“1”的分数开始,竞相用脚撞气球,同时将他们的分数乘以他们撞坏气球上的数字。一分钟后,让小观众把剩下的气球拿走,每位参赛者报告他她的分数,他她撞到的气球上的数字的乘积。非官方获胜者是宣布最高分的玩家。 但是,不可避免地会出现争议,因此在争议解决之前,无法确定正式获胜者。声称得分较低的玩家有权挑战他/她的对手的得分。分数较低的玩家

具身机器人和通用AI 660
上一篇: CodeForces 732E - Sockets(优先队列)
下一篇: ZOJ 1004 Anagrams by Stack
poptree hengli
博客等级 码龄11年 14粉丝 201原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值