SZU5
A - Couple doubi
这种题不要想复杂,直接找规律。找不出规律就打表找规律
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int k,p; int main()
{
int i,j,kase=;
while(sf("%d%d",&k,&p)==)
{
if(k/(p-)%==) pf("YES\n");
else pf("NO\n");
}
}
B - ZCC Loves Codefires
贪心
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int n; struct node
{
int t,a;
double f;
}p[]; int cmp(const node& x,const node& y)
{ return x.f<y.f;} int main()
{
int i,j,kase=;
while(sf("%d",&n)==)
{
for(i=;i<n;i++)
sf("%d",&p[i].t);
for(i=;i<n;i++)
{
sf("%d",&p[i].a);
p[i].f = (double)p[i].t/p[i].a;
}
sort(p,p+n,cmp); long long sumt=,res=; for(i=;i<n;i++)
{
sumt+=p[i].t;
res+=p[i].a*sumt;
}
pf("%I64d\n",res);
}
}
C - Magical Forest(HDU 4941)
双重MAP
D - Task
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
typedef __int64 ll;
const int N=;
using namespace std;
struct node
{
int x,y;
}machine[N],tesk[N];
bool cmp(node a,node b)
{
if(a.x==b.x)
return a.y>b.y;
return a.x>b.x;
}
int main()
{
int n,m,i,j,k,num;
ll money;
int temp[];
while(~scanf("%d%d",&n,&m))
{
for(i=;i<n;i++)
scanf("%d%d",&machine[i].x,&machine[i].y);
for(i=;i<m;i++)
scanf("%d%d",&tesk[i].x,&tesk[i].y);
sort(machine,machine+n,cmp);
sort(tesk,tesk+m,cmp);
memset(temp,,sizeof(temp));
for(i=,j=,money=,num=;i<m;i++)
{
while(machine[j].x>=tesk[i].x&&j<n)//标记符合时间条件的机器
{
temp[machine[j].y]++;
j++;
}
for(k=tesk[i].y;k<=;k++)//判断是否有能完成测试的机器
{
if(temp[k])
{
temp[k]--;
num++;
money=money+*tesk[i].x+*tesk[i].y;
break;
}
}
}
printf("%d %I64d\n",num,money);
}
return ;
}
E - Stupid Tower Defense
dp,分析见:http://blog.csdn.net/u012860063/article/details/38520673
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue LL dp[][]; int main()
{
int i,j,kase=,T;
sf("%d",&T);
while(T--)
{
LL n,x,y,z,t;
sf("%I64d%I64d%I64d%I64d%I64d",&n,&x,&y,&z,&t); LL ans = n*x*t; for(i=;i<=n;i++)
{
for(j=;j<=i;j++)
{
if(j==)
dp[i][j] = dp[i-][j]+(i-)*y*t;
else
dp[i][j] = max(dp[i-][j]+(i-j-)*y*(t+z*j),
dp[i-][j-]+(i-j)*y*(t+z*(j-)));
ans = max(ans,dp[i][j]+(n-i)*(x+y*(i-j))*(t+z*j));
}
}
pf("Case #%d: %I64d\n",++kase,ans); }
}
SZU5的更多相关文章
- mysqldump备份还原mysql
本文实现在mysql 5.7 解压版为例子 1.在window上简单试下一个例子 1.使用管理员权限打开cmd命名行,并切换到mysqldump执行程序下
- 尝试Spring Data Jpa--告别CRUD
前言 说到我们的web开发架构分层中,持久层是相对底层也是相对稳定的一层,奠定好根基后,我们才能专注于业务逻辑和视图开发.而自从ORM思想蔓延开来后,全自动ORM的Hibernate和半自动ORM的M ...
随机推荐
- 3,ThreadGroup 的使用场景以及用法
1 一个大型任务,可分成多个独立的子线程并发进行,最后等待所有的子线程执行结束然后继续往下执行, 使用场景比如 要查找某个用户的最近三个月的通话记录,起 3 个子线程,分别查找最近三个月的记录,然后通 ...
- jxl操作excel单个单元格换行和获取换行
excel中同表格换行: a+"\n"+b 1.读取 String str = sheet.getCell(c, r).getContents(); String[] split ...
- P1979华容道(神仙题)
题目描述 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面, 华容道是否根本就无法完成,如果能完成, 最少需要多少时间. 小 B 玩的华容道 ...
- 对cors的理解
一.简介 CORS需要浏览器和服务器同时支持.目前,所有浏览器都支持该功能,IE浏览器不能低于IE10. 整个CORS通信过程,都是浏览器自动完成,不需要用户参与.对于开发者来说,CORS通信与同源的 ...
- 2.ajax+servlet实现注册时用户名验证
效果: 精灵图(来源:从百度注册中download下来的): userVerify.jsp <%@ page language="java" contentType=&quo ...
- App功能测试的注意点
好几个月没有写博客记录学习心得了,这次回老家深夜闲来无事写一篇记录下这段时间的面试心得,这次面试过程很多面试官都问APP的有关测试,下面我就自己的认识和工作中的经验来谈谈自己对APP测试的认识: 1. ...
- 关于如何爬虫妹子图网的源码分析 c#实现
网上也出现一些抓取妹子图的python 代码,今天我们用c#实现爬虫过程. 请看我的网站: www.di81.com private void www_94xmn_Com(string url, st ...
- train loss与test loss结果分析
train loss 不断下降,test loss不断下降,说明网络仍在学习; train loss 不断下降,test loss趋于不变,说明网络过拟合; train loss 趋于不变,test ...
- js小仓库
1.千分位分隔符 const toDecimalMark = num => num.toLocaleString("en-US"); console.log(toDecima ...
- Centos 7搭建Gitlab服务器(一),搭配文章(二)一起使用,效果更好
一. 安装并配置必要的依赖关系在CentOS系统上安装所需的依赖:ssh,防火墙,postfix(用于邮件通知) ,wget,以下这些命令也会打开系统防火墙中的HTTP和SSH端口访问. 1.安装ss ...