2017CCPC网络选拔赛1005CaoHaha's staff(规律贪心)

2020中国大学生程序设计竞赛(CCPC) - 网络选拔赛 1005 Lunch HDUOJ 6892 Lunch 题目链接 Problem Description Now it’s time for lunch. Today’s menu is chocolate! Though every baby likes chocolate, the appetites of babies are little. After lunch, there are still n pieces of chocolate remained: The length of the ith piece is 阅读详情

2017CCPC网络资格赛1005


描述

“You shall not pass!”
After shouted out that,the Force Staff appered in CaoHaha’s hand.
As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.
But now,his new owner,CaoHaha,is a sorcerers apprentice.He can only use that staff to send things to other place.
Today,Dreamwyy come to CaoHaha.Requesting him send a toy to his new girl friend.It was so far that Dreamwyy can only resort to CaoHaha.
The first step to send something is draw a Magic array on a Magic place.The magic place looks like a coordinate system,and each time you can draw a segments either on cell sides or on cell diagonals.In additional,you need 1 minutes to draw a segments.
If you want to send something ,you need to draw a Magic array which is not smaller than the that.You can make it any deformation,so what really matters is the size of the object.
CaoHaha want to help dreamwyy but his time is valuable(to learn to be just like you),so he want to draw least segments.However,because of his bad math,he needs your help.

输入

The first line contains one integer T(T<=300).The number of toys.
Then T lines each contains one intetger S.The size of the toy(N<=1e9)

样例输入

5
1
2
3
4
5

样例输出

4
4
6
6
7

题意:

  • 意思是在坐标系中,输入给我们一个面积s1,我们需要围出一个面积s2,(s2>=s1)。

  • 如何围出面积,有一定的约束方法。此坐标系平面由无数个单位面积为1的正方形组成,我们每一次可以沿着这个单位的边画一条线,或者是在沿着单位的对角线画一条线。

  • 现在要求最少需要画几次。

思路

  • 其实这个题好像有什么皮克定理,但是不会用。我就按照我的思路讲一下。

  • 首先我们转变一下思路,我们要求得某面积的画的最少的次数,可以转变为某些次数可以得到的最大的面积。那么我们从4条边一直画,最多画到10条的时候,我们可以发现。当画的次数为4,6,8,10,12的时候,面积是1*1*2,2*1*2,2*2*2,3*2*2,3*3*2,也就是说有数m,n就是我们画的面积的长和宽(对于偶数面积来说,一定是一个矩形)。也就是说对于偶数面积,它所需要的最小次数的增长是有一定规律的,总结为,当m==n时,面积为(++m)*n ;当m!=n时,面积为m*(++n).

  • 那画的次数为奇数所能得到的最大面积怎么确定呢?我们可以发现当画的次数为4的时候,长和宽都是1个单位(对角线和沿着边画都算一个单位),那么从4拓展到5,也就是1次画的次数拓展为2次,面积增加0.5;当画的次数为6的时候,长和宽分别是2个和1个单位,那么就是从max(2,1)扩展为1次,也就是2次扩展为3次,面积增加1.5.好了规律出来了,从偶数到奇数的变换,就是偶数的面积加上能够拓展出来的面积,拓展出来的面积又与max(长,宽)有关。

  • 然后打表,读入面积后,就可以二分查找即可。

AC代码


    #include<bits/stdc++.h>
    using namespace std;

    const int maxn = 1e6+5;
    double area[maxn];

    int main()
    {
        area[4] = 2;
        int m = 2,n = 1;
        double temp;
        for(int i = 5;i<=maxn;i++)
        {
            if(i%2 != 0)
            {
                temp = (double)((i+1)/4 - 0.5);
                area[i] = area[i-1] + temp;
            }

            else
            {
                area[i] = m*n*2;
                if(m == n)
                    m++;

                else n++;
            }
        }

    //    cout<<area[maxn];

        int T;
        scanf("%d",&T);
        while(T--)
        {
            double s;
            cin>>s;
            long long ans = lower_bound(area,area+99999,s) - area;
            printf("%d\n",ans);

        }

        return 0;
    }
STM32 CubeMX实战:手把手教你用I2C驱动IST8310磁力计(附完整代码) 本文详细介绍了如何使用STM32 CubeMX和I2C驱动IST8310磁力计,从硬件连接到代码实现的完整流程。重点讲解了I2C通信异常处理、传感器初始化序列优化以及中断驱动数据采集方案,帮助开发者快速搭建可靠的地磁场数据采集系统。 阅读详情

相关推荐

ElasticSearch 集群安全加固实战:从零配置TLS证书与密码认证

本文提供了一份详尽的ElasticSearch集群安全加固实战指南,重点介绍了如何从零开始配置TLS证书与用户安全认证。通过分步讲解证书生成、节点配置、集群重启及密码设置,帮助管理员为ES集群构建通信加密与访问控制的双重防线,有效提升数据安全性与合规性。

weixin_29323493的博客 445

CCPC网赛 CaoHaha's staff(找规律+模拟扩展正方形)

"You shall not pass!" After shouted out that,the Force Staff appered in CaoHaha's hand. As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want. But now,his new owner,CaoHaha,is a

HJY 833

瑞芯微RK3506开发板DSM音频开发避坑指南:从硬件改接到内核配置全流程

本文详细解析了在瑞芯微RK3506开发板上进行DSM音频开发的完整流程与关键避坑点。内容涵盖从硬件改造(如电阻焊接)、内核驱动配置(DTS参数、补丁应用)到系统调试与波形分析的全过程,旨在帮助嵌入式开发者高效实现高信噪比、低成本的音频方案,避免常见错误。

weixin_29164091的博客 415

2026 CCPC/ICPC 官方报名通知、赛事规则、赛事手册

官方报名通知、网络预选赛排名规则、赛事手册

努力向上的大学生一枚⭐ 1154

ANPC三电平拓扑双脉冲试验的原理与实施

ANPC三电平拓扑因损耗低、谐波小、应力均衡而广泛应用,但其存在短、长两类换流通道,寄生电感和开关应力差异显著。短通道尖峰小、可靠性高;长通道应力严苛。因此需分别制定两套独立双脉冲测试方案,针对不同时段和器件(如T1、T5、T6、T4及对应二极管)全面考核开关特性。

嵌入式老牛的博客 376

YOLOv11全网首发:注意力独家魔改 | 具有切片操作的SimAM注意力,魔改SimAM助力小目标检测

1)直接作为注意力使用,效果秒杀SimAM;2)高效和卷积结合,代替原始网络的卷积操作;

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1580

CaoHaha's staff(中国大学生程序选拔赛2017年网络大赛)

Problem Description "You shall not pass!" After shouted out that,the Force Staff appered in CaoHaha's hand. As we all know,the Force Staff is a staff with infinity power.If you can use it skillfu

Dingle_Captain的博客 631

CCPC 网络赛 2017 经验总结

因为太惨不知道写什么 = = 2个小时才过1003 的题,  想复杂了, == , 之前不知道这个定理    超过六个点一定有三元环或者三元独立集 以后输出记得要复制粘贴,今天因为这个还WA了一发,不过已经罚时爆炸了 == 然后找1005的规律找了半天,  发现之后就写出来了,找规律还是出现很频繁啊 最后学姐开了1007题,有一部分的数值想直接算出来,但是太复杂了,

It__is__OK的博客 2125

最新Python爬虫实战(入门爬虫篇)——案例3:爬取二次元cos图片批量下载到本地(附上完整爬虫代码)

本次案例通过Python爬虫技术实现了二次元图片的批量下载。代码采用模块化设计,函数实现cookies的自动解析,简化了配置流程,涵盖“请求列表页→提取详情页URL→请求详情页→提取图片链接→保存图片”的完整流程,与豆瓣案例的核心逻辑和格式完全对齐。学习重点包括:抓包工具定位多层级数据源、正则表达式匹配复杂链接、模拟请求头绕过反爬机制、文件名安全处理及自动化文件管理。需要注意控制请求频率并遵守网站使用规范,适用于入门爬虫实践,帮助学习者掌握多层级页面爬取的核心逻辑。

努力让自己发光,对的人才能迎着光而来 14万+

【WRFDA第三期】OBSPROC namelist 变量总结

OBSPROC namelist 变量总结

WW、forever的博客 1125

2017CCPC网络选拔赛

1007:第一个过的题,数位DP #include using namespace std; typedef long long ll; typedef pair P; #define fi first #define se second #define INF 0x3f3f3f3f #define clr(x,y) memset(x,y,sizeof x) #define PI acos(-1

constbh的博客 1454

【WRF-Urban】使用 CGLC-MODIS-LCZ_100m 数据集运行 WRF 时的城市参数化问题

【WRF-Urban】使用 CGLC-MODIS-LCZ_100m 数据集运行 WRF 时的城市参数化问题

WW、forever的博客 727

2017ccpc网络赛——CaoHaha's staff

"You shall not pass!"  After shouted out that,the Force Staff appered in CaoHaha's hand.  As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to

LSC_333的博客 575

efm32 入门.pdf

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

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

2017ccpc网络预选赛1005

#include #include #define maxl 100000 #define eps 1e-8 int ans; double n; double f[maxl]; void prework() { f[1]=0;f[2]=0,f[3]=0;f[4]=2; for(int i=5;i<maxl;i++) { if(i%4==1)

binarycopycode 739

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

CaoHaha's staff (HDU 6154)(2017中国大学生程序设计竞赛 - 网络选拔赛)

Problem Description "You shall not pass!" After shouted out that,the Force Staff appered in CaoHaha's hand. As we all know,the Force Staff is a staff with infinity power.If you ...

weixin_30597269的博客 217

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

2018年 CCPC 网络赛 赛后总结

      历程:由于只是网络赛,所以今天就三开了。一开始的看题我看了d题,zz和jsw从头尾看起来,发现c题似乎可做,和费马大定理有关,于是和zz一起马上找如何计算勾股数的方法,比较慢的A掉了,而jsw此时看了最后的两道题,并且也与此同时把倒数第二题做掉了,但是此时hdu评测机炸了,判题队列排到几十页之后,所以不知道是否ac,然后就开始想最后一道题目,我和zz想了一下以为是一道类似dp或者图论题...

ysk850874665的博客 1687

CaoHaha's staff(规律,2017中国大学生程序设计竞赛 - 网络选拔赛)

CaoHaha's staff Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 825    Accepted Submission(s): 474 Problem Description "You shall not p

thoughtspark的博客 576

2017CCPC 网络选拔赛 1003 Friend-Graph

http://acm.hdu.edu.cn/showproblem.php?pid=6152 给一张图,0代表不是朋友,1代表是朋友,问存不存在至少有三人互相不是朋友或者是互相是朋友的情况。 模拟暴力,套三层循环,枚举三个不同的人来判断,注意要剪枝避免重复计算。 关键:这道题里 朋友的朋友不是朋友,天哪。。。 #include #include #include #incl

三水的鱼塘♂ 814

几何图形找规律——CaoHaha's staff

**题目:**Problem - 6154 http://acm.hdu.edu.cn/showproblem.php?pid=6154Problem Description“You shall not pass!” After shouted out that,the Force Staff appered in CaoHaha’s hand. As we all know,the Forc

sunandstarws的博客 646

HDU 6154-CaoHaha's staff(ccpc)

Problem Description “You shall not pass!” After shouted out that,the Force Staff appered in CaoHaha’s hand. As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,i

知足常乐的博客 673

CCPC 网络赛

array 做法 比赛中的表现..... 已经无法言语形容了。 题意是,查询前缀中大于某个数字的 mex,在线。 一下把问题转化为偏序问题.... 带修主席树?????这下好,直接一箭穿心,武将被移除。 问题出在于总想对 a 序列的每个前缀维护 xxx 信息。 注意到答案不会超过 \(n+1\) 权值线段树,维护每个值出现的位置。 查询值大于等于 k 的,出现位置大于 r 的,最小值。...

weixin_30828379的博客 264

2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛(解题报告)

In recent years, CCPC has developed rapidly and gained a large number of competitors .One contestant designed a design called CCPC Windows .The 1-st order CCPC window is shown in the figure: And the ...

weixin_44313771的博客 1140

2016CCPC网络赛个人总结

今天下午是2016年的CCPC中国大学生程序设计竞赛的网络赛。几百个学校共计一千多个队参赛。在HDOJ举行。12点开始以后,我们马上看了第一题,嘻嘻哈哈两个星球有着不同的公转周期。给出一个时间。当过了这么多天以后,两个星球是否同时处在一年的第一天。给出的数据的长度不超过一千万。。。第一眼看成了大小不超过一千万。这是一道卡时间的高精度除法题。求一个高精度的数分别除以两个低精度的数。所得到的余数是否同

ACM_Frank的博客 6980

2018CCPC网络预选赛1001(hdu6348) 贪心+优先队列

Buy and Resell 问题分析 题意:有nnn个村庄,每经过一个村庄你有以下三个选择 1. 买能量块 2. 卖能量块 3. 什么也不做 求最后可以获得的最大利润,并且尽可能减少交易次数。 我们可以准着低买高卖的原则,用一个小顶堆维护我们交易过的能量块。 只要当前能量块iii的价格高于我们之前买来的能量块jjj的价格,我们就可以将其卖出去,并且一定是获利的,但是这样做...

Eternally831143的博客 578

hduoj 6000 && 2016CCPC-final B. Wash(贪心)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6000 先求出所有衣服单独洗完的最快时间 再求出所有衣服单独烘干的最快时间 之后两个拼在一起就行了,当然是当前最慢的和当前最快的拼 #include #include #include using namespace std; #define LL long long typedef

加载中... 645
上一篇: 线段树基础与模板与简单应用
下一篇: HDU 6024 Building Shops(DP)
WaveBridge
博客等级 码龄10年 8粉丝 26原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值