HDU - 6195 cable cable cable

题意:如下图,有K个光源,一个光源可同时照射一个显示屏,问从M个显示屏中任选K个,可以使每个显示屏都被不同光源照亮最少需要多少连接电缆。

分析:画图分析可知

1、选1~K个显示屏和选M-K+1~M个显示屏对于所有灯泡来说是两个极限照射范围

2、比如,对于第一个灯泡,选1~K个显示屏他要照到第一个显示屏,选M-K+1~M个显示屏他要照到第M-K+1个显示屏,所以他的照射范围是M-K+1,有K个灯泡,所以K * (M - K + 1)。

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define lowbit(x) (x & (-x))
const double eps = 1e-8;
inline int dcmp(double a, double b){
    if(fabs(a - b) < eps) return 0;
    return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 10000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
int main(){
    LL M, K;
    while(scanf("%lld%lld", &M, &K) == 2){
        printf("%lld\n", K * (M - K + 1));
    }
    return 0;
}

  

时间: 2024-08-24 01:06:20

HDU - 6195 cable cable cable的相关文章

hdu 1551 Cable master(二分)

Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2003    Accepted Submission(s): 751 Problem Description Inhabitants of the Wonderland have decided to hold a regional programming co

Cable master HDU - 1551 —— 二分基础模板(精度问题)

Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants using a "star&

HDU 1551 Cable master【二分答案】

题意:给出n块木板,它们分别的高度,现在要把它们裁切成k块,问裁切成的最大的高度 二分答案,上限是这n块木板里面的最大值 然后每一个答案去判断一下是否满足能够裁切成k块 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<stack> 6 #include<vector> 7 #include<map&

A - Cable master (HDU - 1551)

- 题目大意 有n条绳子,分成k段相等的,问能使得最长为多长. - 解题思路 采用二分法一直逼近求极限状态(注意精度!!!). - 代码 #include<iostream> #include<cmath> #include<iomanip> using namespace std; int n, k; double num[10001]; bool find(double x) { int qum = 0; for (int i = 0; i < n; i++)

ZJU 2676 Network Wars

Network Wars Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original ID: 267664-bit integer IO format: %lld      Java class name: Main Special Judge Network of Byteland consists of n servers, connected by m optical cable

ZOJ 2676 Network Wars(最优比例最小割)

Network Wars Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge Network of Byteland consists of n servers, connected by m optical cables. Each cable connects two servers and can transmit data in both directions. Two servers of the n

DSP开发资源总结,经典书籍,论坛

OMAP4开发资源总结: 一.TI OMAP4官网介绍: http://www.ti.com.cn/general/cn/docs/wtbu/wtbuproductcontent.tsp?templateId=6123&navigationId=12843&contentId=53243 二.OMAPpedia.org,This site has information on various projects in the communityaround OMAP platforms ht

ZOJ 2676 Network Wars[01分数规划]

ZOJ Problem Set - 2676 Network Wars Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge Network of Byteland consists of n servers, connected by m optical cables. Each cable connects two servers and can transmit data in both direction

java程序员认证考试题库

第一部分 基础知识练习 目标 本章对应于<学生指南>各章的内容分别提供了练习题集,包括: ●  第一章Java入门 ●  第二章数据类型和运算符 ●  第三章流程控制与数组 ●  第四章封装 ●  第五章继承 ●  第六章抽象类与接口 ●  第七章多态 ●  第八章异常 ●  第九章多线程机制 ●  第十章输入输出流 ●  第十一章使用泛型和集合框架 ●  第十二章基于Swing的图形用户界面(GUI)设计 ●  第十三章Java事件驱动编程 第一章练习题(Java入门) 1.下列哪项不是JD