【ACM打卡】ZOJ 1067 1115

无GPS室内飞行:基于PX4与MID360的FAST-LIO定点悬停实战解析 本文详细解析了基于PX4飞控与大疆MID360激光雷达的无GPS室内飞行技术,重点介绍了FAST-LIO算法在定点悬停中的应用。通过硬件配置、软件环境搭建、坐标系转换等实战经验,帮助开发者解决室内定位难题,实现精准悬停与稳定飞行。 阅读详情

1067  

输入16组三维坐标(二维数组,for循环至16);

输入其他R G B(直到三个值为-1 -1 -1结束,break跳出循环),利用假循环while(1)输出(里面嵌套for循环判断最短距离的点)结果。


1115

输入一个整数,各个位数相加,直至最后为个位数。

这是我第一次在ZOJ中使用 函数 以及 递归 的思想。但是还有很多地方不明白,如(int)(void)()三者区别,有时候就是无法编译;string.h(strlen为长度)与string(length为长度)的区别。以后继续努力。

问题:

int main(void)
{
    int a;
    while(cin>>a&&a!=0){
    cout<<digitroot( a)<<endl;
    }
}

数字可能很大,这样的主函数无法AC,应该用字符串来输入(借鉴了别人的代码,然后AC)。

int main(void){

    string s;
    while(cin>>s&&s[0]!='0'){
        int a = 0;
        for(int i=0; i<s.length(); i++){
            a = a + s[i] -'0';                            //char转换为int
        }
        cout<<digitroot(a)<<endl;             //digitroot函数
    }

}


by the way,今天的题看起来都很简单,最后都是借鉴了别人的经验才通过的。以后不要所有东西都定义为int,有时候数组、字符串是不错的选择。微笑微笑微笑


1067

#include<iostream>
#include<stdio.h>
using namespace std;

int a[16][3];
int main(){
    int i;
    int R,G,B;
    int m,n,k;
    for(i=0;i<16;i++){
        cin>>a[i][0];
        cin>>a[i][1];
        cin>>a[i][2];
    }
    while(1){
        int m=-1,n=-1;  //利用-1判断,0不可以(不知道为什么)

        cin>>R>>G>>B;
        if(R==-1&&G==-1&&B==-1) break;

        for(i=0;i<16;i++){
            m=(R-a[i][0])*(R-a[i][0])+(G-a[i][1])*(G-a[i][1])+(B-a[i][2])*(B-a[i][2]);
            if(n==-1||m<n){
                n=m;
                k=i;
            }
        }
        printf("(%d,%d,%d) maps to (%d,%d,%d)",R,G,B,a[k][0],a[k][1],a[k][2]);
        printf("\n");

    }

}


1115

#include<iostream>
#include<string>
using namespace std;
int digitroot( int a)
{
    int dr = 0;
    while( a > 0)
    {
    dr += a%10;                                //dr累计所有位数求和
    a /= 10;
    }
    if( dr > 9)
    return digitroot( dr);                     //递归思想,若不为个位数,继续函数
    return dr;
}

int main(void){
    string s;
    while(cin>>s&&s[0]!='0'){
        int a = 0;
        for(int i=0; i<s.length(); i++){
            a = a + s[i] -'0';                //char转换为int
        }
        cout<<digitroot(a)<<endl;             //digitroot函数
    }
}


LPDDR6来了!到底比LPDDR5/5X强在哪?从速度到总线,技术细节一次说清! LPDDR6不仅仅是速度快点、位宽大点那么简单,它是一次架构级的革新,从引脚、总线、时钟管理到Burst协议全部升级。🎯我们正在迈入一个“AI优先”的时代,内存架构也必须跟上。对于做芯片、做整机、做系统的你,理解LPDDR6的技术变化,提前规划测试方案,是现在就该启动的动作! 阅读详情

相关推荐

Claude Skills 深度讲解

阶段 1:Function Call(2023)├─ 大模型可以调用外部工具├─ 问题:缺乏对任务的深度理解└─ 局限:工具调用简单线性阶段 2:MCP 上下文工程(2024)├─ 大模型有了更丰富的上下文和工具├─ 问题:仍然需要手动编写复杂的 Prompt└─ 局限:每次对话都需要重新加载上下文阶段 3:Claude Skills(2025)├─ 大模型有了「能力模块」的概念├─ 可以动态加载、组合、执行专门的工作流├─ 真正实现了「知识的模块化和复用」

u013134676的博客 1465

【ZOJ 1067】Color Me Less 题解(向量+开方)

问题颜色缩减是从一组离散颜色到较小颜色的映射。这个问题的解决方案需要在标准的24位RGB颜色空间中执行这样的映射。输入由十六个RGB颜色值的目标集合和要映射到目标集合中最接近的颜色的任意RGB颜色集合组成。为了我们的目的,RGB颜色被定义为有序三元组(R,G,B),其中三元组的每个值都是从0到255的整数。两种颜色之间的距离被定义为两个三维点之间的欧几里得距离。也就是说,给定两种颜色(R1,G1,B1)和(R2,G2,B2),它们的距离D由下式给出输入。

HEX9CF的技术博客 821

中国知网文献引用导入EndNote9.X,Web of science导入endnote以及谷歌学术导入endnote图文详解,全网最细版本适用EndNote9.x,Endnote20版本

在科研中用到EndNote管理文献,遇到插入文献时,中国知网如何将参考文献导进Endnote9.x或者web of sicence,谷歌学术如何将文章,文献导入进文献管理软件EndNote的详细图文2022版本解释,全网最细的笔记教程,值得大家参考收藏学习

sakura的博客 5179

C语言tzoj1067答案,zoj 1067

输入一组RGB颜色列表,每行一个颜色,是三个从0~255的整数前16行是目标颜色组,-1 -1 -1表示结束16组颜色以后接下来的几行是需要判断的,看它和哪个颜色的距离D最小,找出这个对应的颜色注意空格括弧等等#include#includeusing namespace std;struct Color{int R,G,B;}map[];int main(void){int i,r,g,b,mr...

weixin_34597791的博客 943

GD32F303调试小记(一)之USART(接收中断、接收空闲中断+DMA、发送DMA)

前言 之前写了GD32F103调试小记(二)之USART(接收中断、接收空闲中断+DMA、发送DMA)一文。这次我们来看看GD32F303的USART是如何配置的,结合这两篇文章,相信大家GD32的USART配置流程会十分熟悉。 DMA 能大大减轻CPU负荷的东西,建议场景合适的情况下,都去用DMA功能。 USART 一种串行通信协议, ...

欢喜6666的博客 3万+

STM32驱动电磁阀电路设计:从光耦选型到MOSFET驱动的实战解析

本文深入解析了STM32驱动24V电磁阀的完整电路设计,重点探讨了光耦选型与MOSFET驱动两大核心环节。针对电平转换与电气隔离需求,详细对比了EL357N与TLP2310等光耦在CTR、速度及耐压等关键参数上的差异与应用场景。同时,文章提供了MOSFET关键参数解读、驱动电路优化方案(如推挽驱动)以及完整的PCB布局、电源处理与调试避坑指南,旨在帮助工程师构建稳定可靠的工业控制电路。

weixin_29184371的博客 235

ZOJ_1067_Color Me Less

Color Me Less Time Limit: 2 Seconds      Memory Limit: 65536 KB Problem A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires th

博观而约取,厚积而薄发 760

Flow Matching实战:5步搞定图像生成模型优化(附PyTorch代码)

本文提供了一份基于Flow Matching框架优化图像生成模型的实战指南。通过五个关键步骤,详细讲解了从环境配置、核心概念梳理到构建向量场网络、设计损失函数、编写训练循环以及选择ODE求解器进行采样的完整流程,并附有可运行的PyTorch代码,帮助开发者快速掌握这一高效的生成式建模技术。

weixin_29065959的博客 322

C++ Zoj 1067 Color Me Less

题目大意是: 输入:         先输入16组RGB的值(每行输入一组)         接着输入每组测试数据(RGB的值),以-1 -1 -1结束程序 输出:        先求出测试数据RGB的值与之前的16组目标RGB数据中哪组的D值最小         然后输出这D值最小的组   实现程序: AC #include &lt;iostream&gt; usi...

ChanJose的博客 550

FPGA资料分享——FPGA开发板入手指南

FPGA学习,开发板怎么选,看这里,就一个通透

weixin_51627076的博客 7301

四大AI编程工具深度对比:Claude Code、Codex、OpenCode与WorkBuddy选型指南

AI编程助手正从代码补全走向自主执行的智能体形态,其核心原理是通过“规划-执行-观察”循环让模型自主完成文件修改、命令运行与错误修复。这类工具的技术价值在于提升长任务连续性与上下文理解能力,同时通过自定义指令与技能机制沉淀团队规范,适应不同工程场景。在实际选型中,开发者常面临终端CLI与图形化工作台、模型开放程度与绑定生态之间的权衡:Claude Code强调深度Agent体验,Codex支持灵活接入OpenAI兼容模型,OpenCode以开源多模型见长,WorkBuddy则提供全流程集成环境。本文基于真实

weixin_42526166的博客 139

zoj1067

zoj1067

zzu-hust-madd 794

Qt | QPalette 类(调色版)

Qt | QPalette 类(调色版)

Qt历险记,专注Qt技术,三年医疗设备研发经验,1年机器视觉研发经验,半年柔性传感研发经验。 778

ZOJ-1067 基本运算题

1067:给出16种RGB值作为基准,将后来的颜色值映射到距离最近的颜色。 距离的定义为 [img]http://dl.iteye.com/upload/attachment/535836/5a7b96b5-aa22-31a7-ab2d-3999293b3709.gif[/img] Example Input 0 0 0 255 255 255 0 0 1 1 1...

linest 267

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

zoj-1067

简单题,写不出,很难受。 为什么写不出呢? 首先看题,知道题意是让16位之后的每一个数与前16个数进行COLOR运算,并输出最小的那个数。 一开始是想到计算出该位置与前16个位置的16个答案并得出哪一个最小的,之后在进行一次运算让运算结果等于这个最小值的位置输出。 这样的话机会很累。 所以附上自己改良后的代码,其核心部分的内容是: 首先定义一个min1使其很大,之后循环16次,让每一次

scanferror的博客 471

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

Python ZOJ1067 Color Me Less

从题目里我们知道,我们需要把这些RGB颜色储存起来,而在后面每一个RGB2都要计算与目标集合里的每一个RGB1的距离进行比较,要经常访问RGB(R, G, B)所以一个较为有效的储存方式显得尤为重要。接下来的输入直到出现"-1 -1 -1" 的结束标志前,都是RGB2(R2, G2, B2)我们在题目中主要访问的是RGB中的变量R、变量G和变量B,所以何不为RGB创建一个类?我们要做的,则是找出每一个RGB2对应的最近的RGB1。两个RGB颜色之间的“距离”公式如图。“-1 -1 -1”是输入的集合标志。

m0_73353724的博客 238

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

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

ZOJ 1067

#include struct color {     int R;     int G;     int B; }; int f(int a, int b, int c) {     int sum;     sum = a*a + b*b + c*c;     return sum; } int main() {     color c[16];     int

WuchangI的博客 454

zoj--1067--Color Me Less

水题一枚,主要是英语不行,导致读懂题意花了一段时间

荒野孤鹰 679

zoj 1067很简单

#include #include #include #include int main() {         int a[17],b[17],c[17];         int i,k,p,t,q,x,y,z;         for(i=0;i

603

zoj 1067 Color Me Less

正确代码: #include #include #include using namespace std; int main() { int tar[16][3]; for(int i=0;i<16;i++) for(int j=0;j<3;j++) cin >> tar[i][j]; int color[100][3]={0}; int m=0,n=0,count=0;

zeron_oo的专栏 691

ZOJ1067

简单题,我用dfs求关系的,没用栈的非递归方式,最后想说一句网上看到的读取一个数字的方式 sscanf(str+pos,"%d%n",&sum,&n)...其中%n表示至此已读入的字符数,在这道题中比较有用,学到了~#include #include int n; int g[52][52],d[52]; char s[300]; int cnt; void dfs(int x) {

终究我要华丽逆袭 982

ZOJ1067-Color Me Less

#include #include struct stdcolor { int R; int G; int B; }; stdcolor col[16]; double distance(stdcolor c, stdcolor co) { double dis; dis = pow(c.R - co.R, 2) + pow(c.G - co.G,

Collider 517

ZOJ1067Color Me Less

#include using namespace std; #define N 16 int main() { int R[16],G[16],B[16]; int r,g,b; for(int ii=0;ii<N;ii++) //读入目标集合 cin>>R[ii]>>G[ii]>>B[ii]; while(1) { cin>>r>>g>>b; if(r==-1 &&

香小鱼 639

Zoj1067

水题,就直接上代码了:#include using namespace std; struct Color { int r,g,b; }c[16]; int cmp(Color c1,Color c2) { return (c1.r-c2.r)*(c1.r-c2.r)+(c1.g-c2.g)*(c1.g-c2.g)+(c1.b-c2.b)*(c1.b-c2.b); } int ma

Akai_Shuuichi的专栏 994

【ACM打卡】ZOJ 1037 1049

1037  简单题,看着图形吓蠢了,然后看了下解析,自己画图找规律。n*m个点组成的矩形路线,不重复走回路,输出长长度。找规律:都不为偶数时,m*n+0.41;其他,m*n。  昨天弄了超级久,因为没发现格式要求 a blank line,笑嘻嘻了。 1037 #include #include using namespace std; int main(){

「谁定义我是我」 2763
上一篇: 【ACM打卡】ZOJ 1334
下一篇: 【ACM打卡】2176
annaPresident
博客等级 码龄12年 37粉丝 67原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值