nyoj-1365-山区修路

内存限制:128MB 时间限制:3000ms 特判: No
通过数:4 提交数:4 难度:3

题目描述:

SNJ位于HB省西部一片群峰耸立的高大山地,横亘于A江、B水之间,方圆数千平方公里,相传上古的神医在此搭架上山采药而得名。景区山峰均在海拔3000米以上,堪称"华中屋脊"。SNJ是以秀绿的亚高山自然风光,多样的动植物种,人与自然和谐共存为主题的森林生态区。
SNJ处于中国地势第二阶梯的东部边缘,由大巴山脉东延的余脉组成中高山地貌,区内山体高大,高低不平。 交通十分不便。
最近,HB省决定修一条从YC市通往SNJ风景区的高速公路。经过勘测分析,途中需要经过高度分别为H1,H2,……,Hn的N个山区。由于高低不平,除正常的修路开支外,每段还要多出高度差|Hi - Hi-1|*X万元的斜坡费用。Dr. Kong 决定通过填高一些区域的高度来降低总的费用。当然填高也是需要一些费用的。每填高Y单位,需要付出Y2万元费用。
你能否帮Dr. Kong做出一个规划,通过部分填高工程改造,使得总的费用降下来。

输入描述:

第一行: T 表示以下有T组测试数据( 1≤ T ≤8 )
对每组测试数据,
第一行:N X(2 ≤ N ≤100,000 1≤ X ≤100)
第二行:N个整数,分别表示N个区域的高度Hi( 1<=Hi<=100 , i=1…. n)

输出描述:

对每组测试数据,输出占一行,一个整数,即经过部分填高工程改造后的最少费用。

样例输入:

复制

1
5 2
2 3 5 1 4

样例输出:

15

提示:

上传者:root

  比赛时候想到正解,没敢写,真不知道100亿的复杂度0ms,真是醉了= =

 #include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
int f[][];
int a[];
int main(){
int t,n,X,m,i,j,k;
cin>>t;
while(t--){
int maxh=;
cin>>n>>X;
for(i=;i<=n;++i) scanf("%d",a+i),maxh=max(maxh,a[i]);
memset(f,inf,sizeof(f));
for(i=a[];i<=maxh;++i) f[][i]=(i-a[])*(i-a[]);
for(i=;i<=n;++i){
for(j=a[i];j<=maxh;++j){
for(k=a[i-];k<=maxh;++k){
f[i][j]=min(f[i][j],f[i-][k]+(j-a[i])*(j-a[i])+abs(j-k)*X);
}
}
}
int ans=inf;
for(i=;i<=maxh;++i)ans=min(ans,f[n][i]);
cout<<ans<<endl;
}
return ;
}

1370-Attack City and Capture Territory

内存限制:128MB 时间限制:3000ms 特判: No
通过数:1 提交数:1 难度:2

题目描述:

The Three Kingdoms period was a relatively famous period in the history of China. From the Battle of Chibi (AD 211) to the reunification of China in the Western Jin Dynasty(AD 280). During the period, Cao's Wei State, Liu's Shu State, and Sun's Wu Guo's Three Kingdoms stood together. Therefore, it was called the Three Kingdoms period.

In the last years of the Eastern Han Dynasty, Dong_ Z specialized in power , the coalition forces of the world's princes crusade against each other. Among them, Liu_B and Sun_Q, who are school students, also participated in the crusade.

In AD 215 , Liu_B and Sun_Q simultaneously attacked JingZhou and directly threatened Dong Z's city. There were N firepower points on the high wall, each fire point with different s trength Xi . Liu_B and Sun_Q looked at the high walls and the strong gates, they did not attack the city traightaway. They negotiate to attack firepower point alternately. Who breaks through the last firepower point, he will win the city.

Because of limited weaponry, weapons of each side can only attack one firepower at a time. But they can control whether completely destroy this firepower point or weaken the strength of firepower point.

Liu_B has a strong think-tank. After calculation, he finds out who will attack first , who will more likely win the city .

输入描述:

The first line of the input contains one integer T, which is the number of  test cases (1<=T<=10).  Each test case specifies:

* Line 1:       N                ( 1 ≤ N ≤ 100 )

* Line 2:      X1 X2… Xn        ( 1 <= Xi<=1000    i=1…. n)

输出描述:

For each test case ,  print  “Liu_B is sure to win.” Or  “Liu_B is not sure to win.” ,  suppose Liu_B first attacks.

样例输入:

复制

3
2
1 3
2
3 3
5
1 2 3 4 5

样例输出:

Liu_B is sure to win.
Liu_B is not sure to win.
Liu_B is sure to win.

提示:

    裸nim博弈。
  

 #include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,m,i,j,k;
cin>>t;
while(t--){
int ans=;
cin>>n;
for(i=;i<=n;++i){
scanf("%d",&k);
ans^=k;
}
ans?puts("Liu_B is sure to win."):puts("Liu_B is not sure to win.");
}
return ;
}

河南省第十一届ACM大学生程序设计竞赛的更多相关文章

  1. 【河南省第十一届ACM大学生程序设计竞赛-D】.求XF+闭包

       如何设计一个好的数据库不仅仅是一个理论研究问题,也是一个实际应用问题.在关系数据库中不满足规范化理论的数据库设计会存在冗余.插入异常.删除异常等现象. 设R(U)是一个关系模式,U={ A1,A ...

  2. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  3. 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server

    点击打开链接 2226: Contest Print Server Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 53  Solved: 18 [Su ...

  4. 山东省第四届ACM大学生程序设计竞赛解题报告(部分)

    2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...

  5. [2012山东省第三届ACM大学生程序设计竞赛]——n a^o7 !

    n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...

  6. angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...

  7. 第八届山东省ACM大学生程序设计竞赛个人总结

    因为省赛,从开学紧张到5月7号.心思也几乎全放在ACM的训练上.因为我还是校台球协会的会长,所以台协还有一些事情需要忙,但是我都给延迟了.老会长一直在催我办校赛,但我一直说 等等吧,因为校赛只能在周六 ...

  8. sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛

    Mountain Subsequences 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There ...

  9. ZZUOJ-1195-OS Job Scheduling(郑州大学第七届ACM大学生程序设计竞赛E题)

    1195: OS Job Scheduling Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 106  Solved: 35 [id=1195&quo ...

随机推荐

  1. 2016NOI冬令营day5

    考试 坑坑坑 无法调试 两个小时写的第一题爆零了 O(n)(n<=200)都能被卡T???数据乱搞吧WOC 10分胸牌滚粗

  2. OpenCV Using Python——基于SURF特征提取和金字塔LK光流法的单目视觉三维重建 (光流、场景流)

    https://blog.csdn.net/shadow_guo/article/details/44312691 基于SURF特征提取和金字塔LK光流法的单目视觉三维重建 1. 单目视觉三维重建问题 ...

  3. bzoj1645 / P2061 [USACO07OPEN]城市的地平线City Horizon(扫描线)

    P2061 [USACO07OPEN]城市的地平线City Horizon 扫描线 扫描线简化版 流程(本题为例): 把一个矩形用两条线段(底端点的坐标,向上长度,添加$or$删除)表示,按横坐标排序 ...

  4. c++标准库多线程入门

    从c++ 11开始,语言核心和标准库开始引入了对多线程的原生支持.如下所示: int doSth(char c) { default_random_engine dre(c); uniform_int ...

  5. 20165310_Exp2实验二《Java面向对象程序设计》

    实验二<Java面向对象程序设计> TDD与单元测试 前期准备: 什么是单元测试? 单元测试(unit testing),是指对软件中的最小可测试单元进行检查和验证.对于单元测试中单元的含 ...

  6. 2018-2019-1 20189218《Linux内核原理与分析》第四周作业

    构造简单的Linux内核 显然用实验楼配好的环境做这个实验太简单了,按照没有困难制造困难也要上的原则,在自己的64位虚拟机上做这个实验. 按照课本(视频)上的步骤一直做下去,到编译生成init时出现了 ...

  7. Package libvirt was not found in the pkg-config search path

    关于pip安装libvirt-python的时候提示Package libvirt was not found in the pkg-config search path的问题解决方法 1.一开始以为 ...

  8. linux下安装/升级openssl

    (2810)  (1) 安装环境: 操作系统:CentOs7 OpenSSL Version:openssl-1.0.2j.tar.gz 安装: 目前版本最新的SSL地址为 http://www.op ...

  9. [BZOJ1060][ZJOI2007]时态同步 树形dp

    Description 小Q在电子工艺实习课上学习焊接电路板.一块电路板由若干个元件组成,我们不妨称之为节点,并将其用数 字1,2,3….进行标号.电路板的各个节点由若干不相交的导线相连接,且对于电路 ...

  10. 【TCP/IP详解 卷一:协议】第十章 动态选路协议

    更为详细的RIP博客解析: RIP理论 距离向量算法的简介: RIP协议V-D算法的介绍 10.1 引言 静态选路修改路由表的三种方法 (1)主机设置时,默认的路由表项 (2)ICMP重定向报文(默认 ...