POJ 3210 Coins (很好的想法题)

富士施乐WC3210_WC3220清零软件_V99 富士施乐WC3210_WC3220清零软件_V99 解码软件 解决红灯不打印的问题 一次解码永久加粉不用换芯片 不用换鼓 解码说明: 首先电脑只接一台打印机,电脑能检测到打印机状态,刷机前先把打印机关机重新开机,预热完毕后就可以开始刷机解码了。 立即下载

http://poj.org/problem?id=3210


这是一道很好的思考题。

关键信息:所求的x是对于任意一种初始情况,使所有硬币正面或反面朝上的最少翻转此数,并且注意“only one coin could be flipped each time”,即每次只能翻转一枚硬币。
所以:
1. 答案要具有普适性,除了n为1时x=0,当n>1时x必为正,但是对于硬币全部朝上的情况也要翻转x次,由此可以得出:必须翻转偶数次;
2. 若n为偶数,考虑正面和反面都为奇数个硬币的情况,此时翻转次数必为奇数,矛盾,故此时No Solution;
3. 若n为奇数,则正面和反面的硬币数必为一奇一偶,那就不会出现“必须”翻转奇数次的情况(翻转偶数的硬币即可),所以x可能存在。
那我们来看看x的上界是多少:x不会大于n,反之,那对于任何情况至少会有一个硬币翻转了2次,不符合“最少”的要求,所以x<=n,但是n是奇数,x又必须为偶数,所以x<=n-1
那x的下界呢?来看看只有一个硬币朝上其余硬币都朝下的情况:若翻转那个朝上的硬币,则翻转次数必为2k+1,矛盾,所以我们应翻转其余n-1个朝下的硬币,这样x>=n-1
由这两个不等式可以得出当n为奇数时x必然存在,并且x=n-1


(代码就不贴了)


当然你觉得这题不过瘾的话还可以看看这道差不多(思考多,代码短)的题:POJ 2484 A Funny Game

施乐清零软件 立即下载

相关推荐

从零配置Archery:手把手教你用Docker部署多数据库审核系统(MySQL/PostgreSQL/ClickHouse)

本文详细介绍了如何从零开始使用Docker部署Archery多数据库审核系统,涵盖MySQL、PostgreSQL和ClickHouse的配置与整合。文章提供了生产级Docker-compose配置、审核规则定制、工单流程设置以及企业微信通知集成等实战指南,帮助团队构建统一的企业级SQL审计平台,提升数据库操作规范与安全。

e4f5g6h7的博客 951

Poj 3210 Coins(思维)(矛盾推理)

题目意思是掷硬币,要求最少掷多少次能使全部硬币朝向一致。 分析: 当硬币个数是偶数时,硬币面有两种情况,一种正面为偶数个,反面是偶数个,另一种是正面奇数个,反面奇数个。第一种情况最少掷偶数次,第二种情况最少掷奇数次,二者矛盾,所以该情况下输出no solution。 当硬币个数是奇数时,情况是奇数个正面,偶数个反面,反之也成立。在这种情况下最少情况就是翻转一次,但是满足情况的最小的只有n-1 #i...

Nerdant 320

逆变器专题(6)-正负序分离(二阶广义积分器DSOGI)

相应仿真原件请移步资源下载DSOGI作为一种常用的正负序分离方法,其可以在电压三相不平衡的状态下实现较为精准的锁相环。

cyc19980105的博客 8834

POJ 3210(逻辑推理)

Coins Time Limit: 1000MS Memory Limit: 131072K Description Snoopy has three coins. One day he tossed them on a table then and tried to flip some of them so that they had either all heads or ...

Eternally831143的博客 877

深入解析安卓性能分析工具systrace/atrace的使用技巧与实战场景

本文深入解析了安卓性能分析工具systrace/atrace的核心使用技巧与实战场景。文章澄清了环境搭建的常见误区,详细拆解了命令参数,并通过列表卡顿、启动优化等具体案例,手把手指导开发者利用这些工具精准定位性能瓶颈,提升应用流畅度。

yyy34的博客 249

毫米波雷达SLAM实战:如何在无GPS的地下隧道实现精准三维建图(附Python代码)

本文深入探讨了在无GPS信号的地下隧道等拒止环境中,如何利用毫米波雷达SLAM技术实现精准三维建图。文章系统分析了毫米波雷达点云数据稀疏、噪声多的挑战,并提供了从环境配置、核心算法(如特征提取、ICP配准、回环检测)到全局优化的完整实战解决方案,附有可运行的Python代码,帮助开发者构建鲁棒的自主导航与建图系统。

t8u9v0w1x的博客 252

POJ3210-推导

题目:题目链接 题意:Snoopy想问下,若有n枚硬币,这n枚硬币的初始状态是任意的,则至少需要翻转几次,才能保证对于任何一种初始状态而言,都能变成n枚硬币全为正或全为反。   思路:若n为偶数:       1: 若初始状态为偶数正面 + 偶数反面,要想变成全正或全反,翻转的次数必为偶数。          例如: ○○●●●●  则翻转 2,4,6,8……次均可。    

ACM_devil 800

从有限元到实时孪生:Twin Builder静态降阶模型实战指南

本文详细介绍了如何利用Twin Builder构建静态降阶模型(Static ROM),实现从有限元分析到实时数字孪生的技术跃迁。通过实战案例展示了参数化采样、模型训练和FMU导出的完整流程,帮助工程师将仿真速度提升数百倍,适用于机械臂、汽车悬架等结构静力学分析场景。

weixin_28725949的博客 441

POJ-3210-Coins-解题报告

题意: 给定n个硬币,进行x次翻转,每次只能翻转一个硬币,且每个硬币可被翻转多次。 问:对于所有初始情况下的硬币(即正反面的硬币数不一样),直少需要翻转几次才能达到所有硬币均处于同一面的状态。 分析: 1. n为偶数。 1)若所有硬币均处于同一面,最小翻转次数x一定是偶数。 2)若不是所有硬币均处于同一面,则一定是以下两种情况: i. 正面数为奇,反面数也为奇。最小翻转次数一定为奇。

Leo的博客 2007

matlab 质心重合法实现点云配准【2027最新版】

质心重合法是将源点云和目标点云的质心重合,以此缩小两点云集之间的平移误差,从而为下一步粗配准提供更好的初始位置姿态。

点云侠的博客 516

【机器学习-09】特征工程

特征工程是机器学习模型构建的初步工作,但它的重要性却贯穿整个模型生命周期。在进行特征工程时,我们需要充分利用数据科学的知识和技巧,结合具体的应用场景和业务需求,来制定出最合适的特征提取和转换策略。只有这样,我们才能为机器学习模型提供最有价值的输入,从而使其发挥出最大的潜力。总之,特征工程是机器学习中的一项关键任务,它需要我们用心去探索、去实践、去创新。只有不断地优化和完善特征工程的过程,我们才能构建出更加准确、更加可靠的机器学习模型,为实际应用带来更大的价值。

qq_38614074的博客 2万+

POJ-3210(翻转硬币必须k次使其同面)(Coins)

【题目描述】 桌子上有N枚硬币,翻转X次(必须是N次,不能多也不能少)。同一硬币可以翻多次。使得不论原始状态如何,翻完后硬币是同一面朝上。 【解题思路】 当N为偶数时无解,当N为奇数时结果为N-1.由于解法简单,就不贴代码了~ 分析: 1. 若N为偶数。两种硬币的组合可能是(奇数+奇数)或者(偶数+偶数)。当正面硬币数目和反面硬币数目均为偶数时,想要同一面朝上,翻转次数必为偶数。

famousDT的专栏 1375

Python之afdx包语法、参数和实际应用案例

Python 的 afdx 包是针对 AFDX 协议的轻量级开发工具,专注于 AFDX 数据帧的解析、构造、发送/接收、协议合规性校验等核心能力,广泛应用于航空电子设备测试、仿真、数据监控等场景。

王国平的博客 993

POJ 3210 : Coins

POJ 3210 : CoinsTime Limit: 1000MS Memory Limit: 131072K Total Submissions: 7001 Accepted: 4616DescriptionSnoopy has three coins. One day he tossed them on a table then and tried to flip some

1525

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

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

【原】 POJ 3210 Coins 巧妙的简单题 解题报告

http://poj.org/problem?id=3210 方法: 当n个硬币初始同面,则只能偶次翻转才能保持同面,所以答案肯定是偶数。 n为偶数时,假设1个为正,n-1个为反,两中情况同为奇数,所以只能通过奇数次翻转才能保持同面, 这与上面的情况矛盾,所以n为偶数时无解 n为奇数时,正反的个数必然是一个偶数一个奇数。假设1个为正,n-1个为反...

ajiaxi111111的博客 371

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

poj_3210 Coins

题目链接:http://poj.org/problem?id=3210   //C++代码 //若n为偶数 //1:若初始状态为偶数正面+偶数反面,要想变成全正或全反,翻转次数必为偶数 //2:若初始状态为奇数正面+奇数反面,要想变成全正或全反,翻转次数必为奇数 //因此,无法得到一个确定的翻转次数x,使得对任意初始状态均可通过x次翻转变成全正或全反,故应输出"No Solution!" //

永恒国度 702

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

POJ3210:Coins

点击打开题目链接 Coins Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6488   Accepted: 4236 Description Snoopy has three coins. One day he tossed them

I just want to AC you~~~ 1617

poj 3210 Coins

这事一道英语理解题,看了我好久 就是n枚硬币,无论初始状态如何,都有一个最小值k次翻转使n枚硬币都同向 n为偶数的时候,:n枚同向,则翻转偶数次,有奇数枚反向,则需翻转奇数次才能使全部同向,所以情况不存在 n为奇数,数学归纳。。。。。   #include int main(int argc, char *argv[]) { int n; while(scanf("%d",

Tdreamge的专栏 686

Poj 3210 Coins(推理)

题目:http://poj.org/problem?id=3210 Coins Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 7012   Accepted: 4624 Description Snoopy has three coins. One d

theArcticOcean 897

Coins POJ - 3210

Snoopy has three coins. One day he tossed them on a table then and tried to flip some of them so that they had either all heads or all tails facing up. After several attempts, he found that regardless

liluoyu_1016的博客 311
上一篇: POJ 3211 Washing Clothes (平衡划分&01背包)
下一篇: UVa 10077 The Stern-Brocot Number System (数学)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址