真正的水题,可惜无法当场机智一下。

这样的,在一个圈圈上给你n个黑点,现在要你移动每一个黑点使得所有的点都是等间距的,每个点中最远需要一定的那个点最小可以是多少?

其实是这样来考虑的,我们可以随便设置一系列参考点,不妨直接假设为(0,n/m,2*n/m,……),这样我们直接记录所有的点依次移动到这些对应位置所需要的最大的步奏和最小的步奏,这样我们就得到了到这一系列的位置的最大和最小值。这样我们需要的最终目标位置就是在最大值和最小值的中点处。

这里理解一下吧,就是答案了。。  智商拙计。、、、

#include <iostream>
#include <cstdio>
#include <algorithm>
#define maxn 1000100
using namespace std; int a[maxn],maxpos,minpos,n,m,cas=,t; int main()
{
scanf("%d",&t);
while (t--)
{
scanf("%d%d",&n,&m);
for (int i=; i<=m; i++) scanf("%d",&a[i]);
sort(a+,a++m);
maxpos=,minpos=~0U>>;
for (int i=,cur=; i<=m; i++,cur+=n/m)
maxpos=max(maxpos,a[i]-cur),minpos=min(minpos,a[i]-cur);
printf("Case #%d: %d\n",++cas,(maxpos-minpos+)/);
}
return ;
}

UVALive6442_Coins on a Ring的更多相关文章

  1. 一点公益商城开发系统模式Ring Buffer+

    一个队列如果只生产不消费肯定不行的,那么如何及时消费Ring Buffer的数据呢?简单的方案就是当Ring Buffer"写满"的时候一次性将数据"消费"掉. ...

  2. OpenCASCADE Ring Type Spring Modeling

    OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create ...

  3. 使用Ring Buffer构建高性能的文件写入程序

    最近常收到SOD框架的朋友报告的SOD的SQL日志功能报错:文件句柄丢失.经过分析得知,这些朋友使用SOD框架开发了访问量比较大的系统,由于忘记关闭SQL日志功能所以出现了很高频率的日志写入操作,从而 ...

  4. [AlwaysOn Availability Groups]AlwaysOn Ring Buffers

    AlwaysOn Ring Buffers 一些AlwaysOn的诊断信息可以从SQL Server ring buffers.或者从sys.dm_os_ring_buffers.ring buffe ...

  5. UVa 524 Prime Ring Problem(回溯法)

    传送门 Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbe ...

  6. Ring buffers and queues

    Ring buffers and queues The data structure is extremely simple: a bounded FIFO. One step up from pla ...

  7. Prime Ring Problem

    Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ... ...

  8. hdoj 1016 Prime Ring Problem

    Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ... ...

  9. uva 524 prime ring problem——yhx

      Prime Ring Problem  A ring is composed of n (even number) circles as shown in diagram. Put natural ...

随机推荐

  1. bootstrap学习笔记(4)

    bootstrap辅助类 总结几个常用的辅助类 .text-hide将页面元素所包含的文本设置为透明并且字体设置为0所以文本就看不见了 .hidden将页面的元素visible属性设置为hidden; ...

  2. golang安装开发环境配置

    本机系统:fedora28 step 1 百度搜索 golang 到 go 语言中文网,下载 golang 包,如果是 linux 系统可以直接点击此连接,也可去 go 语言中文网, https:// ...

  3. 浅谈ajax同步、异步的问题

    最近实习的时候看到过firefox的同步.异步的警告,想着概念不是那么清楚,于是整理了一下ajax同步异步方面的知识.我是小白,做个笔记. 首先就是概念问题,ajax根据async进行区分同步和异步过 ...

  4. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 78,050,512 milliseconds ago.

    今天访问已经架上服务器的网站,报错: Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet s ...

  5. 【Unity】 Cursor学习

    CursorLockMode.None 光标行为未修改,第一人称视角下鼠标可以突破窗口. CursorLockMode.Locked 光标锁定到游戏窗口的中心,与全屏与否无关,同时隐藏光标(这一点在3 ...

  6. AI入门课程资源

    企业 kaggle https://www.kaggle.com/learn/overview Google   介绍 https://developers.google.cn/machine-lea ...

  7. 小刘的深度学习---CNN

    前言: 前段时间我在树莓派上通过KNN,SVM等机器学习的算法实现了门派识别的项目,所用到的数据集是经典的MNIST.可能是因为手写数字与印刷体存在一些区别,识别率并是很不高.基于这样的情况,我打算在 ...

  8. UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 0: ordinal not in range(128)的解决

    在用爬虫爬取网络小说的时候出现该问题. 估计是字符格式转换格式的错误. 暂时无法解决,搜索了其他博主的解决方案. 以下两个方案靠谱: <一>适用于全篇 import sys default ...

  9. C++ 类的定义与实现

    摘自这篇博客https://blog.csdn.net/xulingxin/article/details/81335030   一."类" 的介绍     在C++中, 用 &q ...

  10. Scrum立会报告+燃尽图(Final阶段第一次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2480 项目地址:https://coding.net/u/wuyy694 ...