POJ 1166 The Clocks(拨钟问题——枚举)

数据结构,贪心算法,枚举法的典型例题 数据结构典型例题,里面包含了几种典型的数据结构的详细讲解,典型算法,枚举算法,贪心算法..等等..是非常好的培训教材. 立即下载
#define LOCAL

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int clk[10];int num[10];
int main()
{
#ifdef LOCAL
	freopen("/Users/wangkeyuan/i.txt","r",stdin);
	freopen("/Users/wangkeyuan/o.txt","w",stdout);
#endif
	for(int i=0;i<9;i++)
		cin>>clk[i];
	for(int i1=0;i1<4;i1++)
	{
		for(int i2=0;i2<4;i2++)
		{
			for(int i3=0;i3<4;i3++)
			{
				for(int i4=0;i4<4;i4++)
				{
					for(int i5=0;i5<4;i5++)
					{
						for(int i6=0;i6<4;i6++)
						{
							for(int i7=0;i7<4;i7++)
							{
								for(int i8=0;i8<4;i8++)
								{
									for(int i9=0;i9<4;i9++)
									{
										num[0] = (clk[0]+i1+i2+i4)%4;  
                                        num[1] = (clk[1]+i1+i2+i3+i5)%4;  
                                        num[2] = (clk[2]+i2+i3+i6)%4;  
                                        num[3] = (clk[3]+i1+i4+i5+i7)%4;  
                                        num[4] = (clk[4]+i1+i3+i5+i7+i9)%4;  
                                        num[5] = (clk[5]+i3+i5+i6+i9)%4;  
                                        num[6] = (clk[6]+i4+i7+i8)%4;  
                                        num[7] = (clk[7]+i5+i7+i8+i9)%4;  
                                        num[8] = (clk[8]+i6+i8+i9)%4;

                                        int sum=0;
                                        for(int i=0;i<9;i++)
                                        	sum+=num[i];
                                        if(sum==0)
                                        {
                                        	for(int j=1;j<=i1;j++)
                                        		printf("1 ");
                                        	for(int j=1;j<=i2;j++)
                                        		printf("2 ");
                                        	for(int j=1;j<=i3;j++)
                                        		printf("3 ");
                                        	for(int j=1;j<=i4;j++)
                                        		printf("4 ");
                                        	for(int j=1;j<=i5;j++)
                                        		printf("5 ");
                                        	for(int j=1;j<=i6;j++)
                                        		printf("6 ");
                                        	for(int j=1;j<=i7;j++)
                                        		printf("7 ");
                                        	for(int j=1;j<=i8;j++)
                                        		printf("8 ");
                                        	for(int j=1;j<=i9;j++)
                                        		printf("9 ");
                                        	return 0;
                                        }
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return 0;
}

【影像组学】用3Dslicer或Python提取影像组学特征 用3Dslicer或Python提取影像组学特征 阅读详情

相关推荐

基于PLC的茶叶揉捻机自动控制系统设计【附代码】

茶叶揉捻是初茶加工过程中的一道关键工序,通过揉捻可以使鲜茶叶成条、碎茶及叶组织细胞破损等。影响茶叶成条率、碎茶率和叶组织细胞破损的主要因素包括揉捻时间、压力和揉捻桶转速。为了提高茶叶品质的稳定性和减轻工人的劳动强度,本文提出了一种基于PLC自动控制技术的茶叶揉捻机控制系统设计。📊 PLC自动化设计 | 毕业设计指导 | 工业自动化解决方案。✅ 具体问题可以私信或查看文章底部二维码。✅ 感恩科研路上每一位志同道合的伙伴!

lagougongzuoshi的博客 1341

POJ 1488 TEX Quotes(TeX的双引号——getchar)

#define LOCAL #include&lt;cstdio&gt; #include&lt;iostream&gt; using namespace std; int main() { #ifdef LOCAL freopen("/Users/wangkeyuan/i.txt","r",stdin); freopen("/Users/wangkeyuan/o.txt","...

Ericipher的博客 259

oracle两节点RAC,由于gipc导致某节点crs无法启动问题分析

两节点RAC,其中1 节点集群CRS无法启动。经过分析原因为2节点gipcd进程异常,导致节点之间无法正常通信,重启2节点gipcd.bin后问题得以恢复。 从现象来看,是 ora.crsd...

cuibaye0692的博客 4533

POJ 1166 The Clocks(拨钟问题)

描述有9个时钟,排成一个3*3的矩阵。 现在需要用最少的移动,将9个时钟的指针都拨到12点的位置。共允许有9种不同的移动。如下表所示,每个移动会将若干个时钟的指针沿顺时针方向拨动90度。 移动 影响的时钟 1 ABDE 2 ABC 3 BCEF 4 ADG 5 BDE

不若乘风来 1379

RK3566 Android11默认客户Launcher修改

【代码】RK3566 Android11默认客户Launcher修改。

Android系统开发笔记 1723

PCL 基于超体素的点云分割【2024最新版】

点云超体素分割原理介绍、代码实现以及如何做到将每一个超体素内的点进行单独保存而不造成点云缺失的方法。博客长期更新,本文最近一次更新时间为:2024年12月29日。

点云侠的博客 36万+

002:拨钟问题

现在需要用最少的移动,将9个时钟的指针都拨到12点的位置。共允许有9种不同的移动。如下表所示,每个移动会将若干个时钟的指针沿顺时针方向拨动90度。 移动 影响的时钟 1 ABDE 2 ABC 3 BCEF 4 ADG 5 BDEFH 6 CFI 7 DEGH 8 GHI 9 EFHI

wo_ai_luo_的博客 1491

【STM32系统】基于STM32+手机APP设计的智能停车场系统

功能简介1、进出停车场时需要刷卡,进行一个记时、计费的功能。2、停车位配有超声波检测,主要识别车位是否被占用。3、车位区域配有OLED显示屏,用户可以通过显示屏看到空闲车位。4、车位配有车位灯。当用户找不到车位可以通过手机点亮车位灯5、停车场配有温湿度检测和烟雾检测模块。当环境发生异常状态。会触动紧急报警。6、停车场信息会通过Wi-Fi发送数据上传至阿里云。用户可以通过手机了解到停车场空闲车位和停车时间、费用。

嵌入式阿齐Archie 2万+

002 拨钟问题

原理:部分遍历确定整体 一:建立题目给出操作效果 二:遍历前三 三:依前三操作456,后得出789 因为前三操作完,能动A钟只有4,能动B钟只有5,能动C钟只有6 依次确定456,确定完后同理可确定789。 根本确定为何是前三,怎么划分部分:有部分确定整体的思想后,在相互牵连影响复杂的情况下,从1开始试,1不行就2,2不行再3。而在上题复杂密码锁中牵连情况过于简单,只会影响两侧所以1就已经解决了问题,若想深入理解,请试试想想“2”,“3”的各种情况会是什么样的效果。 故是以牵连复杂程度,一个一个试出来的。

lliuxia的博客 270

动力学约束下的运动规划算法——Kinodynamic RRT*算法

动力学约束下的运动规划算法——Kinodynamic RRT*算法

慕羽★的博客 6748

以宠辱之戒写 SAP Fiori Elements,把标准能力当成身体,把扩展冲动当成大患

SAP Fiori Elements开发中常面临业务方追求"独特页面"的压力,但过度自定义会破坏框架价值。老子"宠辱若惊"的智慧提醒开发者:不应因用户称赞或批评而动摇架构原则。标准模板的价值在于确保业务语义、交互规范和后端服务的一致性。扩展应遵循官方API,将业务逻辑放在ABAP/CDS层而非前端控制器。成熟项目会平衡标准与定制,使用annotation表达UI行为,仅在必要时通过受支持的extension points进行增强,保持系统的长期可维护性。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 996

【题解】002:拨钟问题

http://cxsjsxmooc.openjudge.cn/2018t2fallsum/002/ 提示:由特殊密码锁题目得到启示:第一行即为枚举的局部。那么如何寻找第一行的枚举情况呢? 观察:操作123如果被固定,那么由第一行情况可以固定出操作456,再由第二行固定操作79,再根据E和DHI的情况选择 启示:枚举的局部有思路之后要谨慎考虑枚举对象(钟表 or 操作) #include&l...

不知道叫什么的博客 1701

ROS从入门到精通2-1:机器人3D可视化工具——Rviz

本文详细介绍了Rviz是什么?为什么要使用这个工具?清晰地列出了Rviz的安装流程和界面的基本功能元素;讲解了Rviz基本数据类型与话题,并用两个实例深入理解Rviz数据可视化的过程

FRIGIDWINTER的博客 5345

POJ 1166 The Clocks 拨钟问题

POJ 1166 The Clocks 拨钟问题 描述 有9个时钟,排成一个3*3的矩阵。 现在需要用最少的移动,将9个时钟的指针都拨到12点的位置。共允许有9种不同的移动。如下表所示,每个移动会将若干个时钟的指针沿顺时针方向拨动90度。 输入 9个整数,表示各时钟指针的起始位置,相邻两个整数之间用单个空格隔开。其中,0=12点、1=3点、2=6点、3=9点。 输出 输出一个最短的移动序列,使得9个时钟的指针都指向12点。按照移动的序号从小到大输出结果。相邻两个整数之间用单个空格隔开。 样例输入 3

蒟蒻本蒻的博客 356

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

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

POJ 1166 The Clocks

高斯消元第四题,这次的题很精彩~~ 题目大意: 给出9个钟表的状态,给出九种操作,问最少要操作几次能把所有的钟表调回12点。 解题思路: 对于9个钟表分别列方程,然后高斯消元即可。由于这次左边的方程系数不是0就是1,所以不用找最大值~ 下面是代码: #include #include #include #include #include #in

脑残的孩子只有慢慢学。。 7414

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

poj 1166 The Clocks 暴力枚举

poj1166 the clock 链接 关于这个~~ 9个钟表的指针0-4的数, 9个状态进行for循环 遍历每个状态 每个操作不会超过四次,四次之后就重头开始了 贴代码~~ post code: #include #include int clock[10]; int original[10]; int rec[10]; char ch[10][20]={"ABDE","ABC

yangshuolll的专栏 1223

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

POJ1166 the clocks

题目大意:给出原始9个表watch,通过9个操作operation,求最少操作数使得9个watch都指向12点.每一次operation,会对相应涉及到的watch顺时针调整15分钟.   思路: 对于每种操作,操作次数不会超过3次,因为4次以上就会有无意义的步数,为什么无意义?因为和前面的操作状态重复了. 为什么这样会重复呢?其他的操作对表的影响下再操作就不会与重复了呀!这是因为每一次操

muxi@Achilles的专栏 1304

POJ 1166 The Clocks

链接:http://poj.org/problem?id=1166 题目描述: The Clocks Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19016 Accepted: 7879 Description |-------| |-------| |-------| | | | ...

nowting的博客 221

JSON-RPC 2.0为何成为AI Agent Harness通信首选?协议原理与实战解析

在现代AI应用开发中,智能体(Agent)与工具集成的复杂度日益攀升,其背后离不开一套轻量高效的远程过程调用(RPC)协议支撑。JSON-RPC 2.0,这个诞生于XML-RPC与SOAP争霸时代的“老协议”,正因AI Agent生态的爆发而重回技术舞台中心。它采用纯文本、无状态、请求响应与id显式关联的消息模型,天然适配工具调用、技能注册、插件管理等动态交互场景。无论是LangChain等框架中的function calling、MCP规范的会话流程,还是Agent Harness的运行时通信,都将JSO

weixin_34014555的博客 490

POJ1166 The Clocks [枚举]

这题蛮有意思,不知道怎么分类到高斯了, 应该是一道枚举 思路很赞,不多说,看代码 c那个数组很容易初始化错误呢 最后的输出有点搞人,不过也可能不用特别注意最后一个空格 #include #include #include #include using namespace std; int c[10][10]={ {0,0,0,0,0,0,0,0,0,0}, {0

Rainto的专栏 1056

PKU 1166 The Clocks

题目:http://poj.org/problem?id=1166 题意:给出9个时钟的状态和9种操作,每种操作可以改变不同的时钟的状态,每次只能改变90度,输出最少的有序的操作序列 思路:枚举出每种操作的次数,最多为3次,保存在num数组中,判断每个时钟经过9种,每种num[j]次操作,是否为0. #include #include int flag; int state[9],

AC_coder的专栏 746

《搜索》— POJ 1166 The Clocks(搜索枚举)

The Clocks Time Limit:1000MS Memory Limit:65536K Total Submissions:17299 Accepted:7126 Description |-------| |-------| |-------| | | | | | | | ...

69小石头的博客 652

POJ 1166 clocks【DFS】

我查了查,比较好的办法是高斯消元,或者BFS,用不过用9重for循环暴力枚举法可以做出来,真的非常不喜欢太多的for循环,所以寻找能用DFS做出来的解法。 一开始我就用DFS枚举一个一个试,但是可能是数据量太大了,结果总是出不来,原来所有的题都不是死板的相同,都需要动动脑子的。 我非常不甘心,还是把失败的代码打出来先。 int main(void){ // 省略输入输出及其他非核心步骤

weiwanshu的专栏 450

POJ1166The Clocks

在luogu上理解下(就是输入改一下) 直接枚举每一种情况。 然后Run ID User Problem Result Memory Time Language Code Length Submit Time 16993437 huhaoo 1166 Accepted 640K 47MS G++ 2296B 2017-05-13 11:

huhao的博客 271

POJ 1166 The Clocks (暴搜)

POJ 1166 暴搜

芝兰生于深谷,不以无人而不芳 1385
上一篇: POJ 2538 WERTYU(打错字符——制表)
下一篇: OpenJudge MOOC 特殊密码锁(熄灯问题的变型——枚举)
Ericipher
博客等级 码龄9年 0粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值