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. sql study

    -- ============================================= -- Author: lifu -- Create date: 2017-06-14 -- Descr ...

  2. 深入理解Java虚拟机 #01# 自己编译JDK

    x 首先用书上的脚本尝试,失败. 之后根据源文件的 README 编译,抛出: root@linux:/opt/openjdk# sh ./get_source.sh ERROR: Need init ...

  3. 20145322 Exp5 MS08_067漏洞测试

    20145322何志威 Exp5 MS08_067漏洞测试 实验过程 kali ip:172.20.10.4 windows 2003 ip:172.20.10.2 在控制台内使用search ms0 ...

  4. Android 实践项目开发 总结

      Android 实践项目开发 总结 课程:移动平台应用开发实践  班级:201592  姓名:杨凤  学号:20159213 成绩:___________       指导老师:娄嘉鹏       ...

  5. fedora中使用 mariadb数据库建库和建表-- mariadb数据库服务无法启动?

    /proc(进程, 过程等含义) 文件系统是一个虚拟文件系统,通过它可以使用一种新的方法在 Linux® 内核空间(内核)和用户空间(用户)之间进行通信.在 /proc 文件系统中,我们可以将对虚拟文 ...

  6. BZOJ 4552: [Tjoi2016&Heoi2016]排序 线段树 二分

    目录 此代码是个假代码,只能糊弄luogu,以后再改,路过大佬也可以帮一下辣 update 10.6 此代码是个假代码,只能糊弄luogu,以后再改,路过大佬也可以帮一下辣 /* //fang zhi ...

  7. Myeclipse下配置svn

    转载高鑫的..嘻嘻.. MyEclipse安装配置SVN 2013.10.15 No Comments 67 Views 配置之前请先关闭MyEclipse,OK开始了 1.解压site-1.6.18 ...

  8. c++ 容器元素填充(fill)

    #include <iostream> // cout #include <algorithm> // fill #include <vector> // vect ...

  9. 退出shell 脚本

    #!/bin/bash export TOP_PID=$$ trap 'exit 1' TERM exit_script(){ kill -s TERM $TOP_PID } echo "b ...

  10. Nginx 多重条件判断

    server{ listen 80; server_name xxx.com; index index.html index.htm index.php admin.php; root /home/w ...