Contest 4
A:cf原题。当然是不是也没什么关系。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 1000010
int n,a[N];
int main()
{
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
n=read();
for (int i=;i<=n;i++) a[i]=read();
sort(a+,a+n+);
cout<<a[n]-a[]-n+;
return ;
}
B:非常裸的矩乘。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define P 1000000007
#define N 9
int T,n;
struct matrix
{
int n,a[N][N];
matrix operator *(matrix b) const
{
matrix c;c.n=n;memset(c.a,,sizeof(c.a));
for (int i=;i<n;i++)
for (int j=;j<N;j++)
for (int k=;k<N;k++)
c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j]%P)%P;
return c;
}
}f,a,b;
int trans(int x,int y){return x*+y;}
int main()
{
freopen("food.in","r",stdin);
freopen("food.out","w",stdout);
T=read();
a.n=N;f.n=;
for (int i=;i<;i++)
for (int j=;j<;j++)
for (int k=;k<;k++)
if (!(i==j&&j==k)&&!(j==&&i+k==)&&!((j==||j==)&&(i==&&k==))) a.a[trans(i,j)][trans(j,k)]=;
b=a;
while (T--)
{
n=read()-;
if (n<) {printf("3\n");continue;}
a=b;
for (int i=;i<;i++) f.a[][i]=;
for (;n;n>>=,a=a*a) if (n&) f=f*a;
int ans=;
for (int i=;i<;i++) ans=(ans+f.a[][i])%P;
printf("%d\n",ans);
}
return ;
}
C:非常显然的堆。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 100010
#define ll long long
int n,a[N],b[N],cnt;
ll delta;
priority_queue<ll,vector<ll>,greater<ll> >q;
int main()
{
freopen("snow.in","r",stdin);
freopen("snow.out","w",stdout);
n=read();
for (int i=;i<=n;i++) a[i]=read();
for (int i=;i<=n;i++) b[i]=read();
for (int i=;i<=n;i++)
{
q.push(a[i]+delta);cnt++;
ll ans=;
while (!q.empty()&&q.top()<=delta+b[i]) ans+=q.top()-delta,q.pop(),cnt--;
delta+=b[i];
printf("%I64d ",ans+1ll*cnt*b[i]);
}
return ;
}
result:300 rank1
Contest 4的更多相关文章
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contest 2 D. Differencia
Differencia Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- hdu-5988 Coding Contest(费用流)
题目链接: Coding Contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- ZOJ 3703 Happy Programming Contest
偏方记录背包里的物品.....每个背包的价值+0.01 Happy Programming Contest Time Limit: 2 Seconds Memory Limit: 65536 ...
- 2012 Multi-University Training Contest 9 / hdu4389
2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...
- 2014 Multi-University Training Contest 9#11
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others) ...
- 2014 Multi-University Training Contest 9#6
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...
- 校际联合Contest
每次开一个坑都像是重新被碾压的预感 最近的新闻,以前很喜欢乔任梁的<复活>...然后他就死了...感觉我再多愁善感一点的话...就要悲伤逆流成河了吧... Contest 09/24(乐滋 ...
随机推荐
- day 10 文件
1.文本文件 ,二进制文件 二进制文件:用vi 打开一个图片,MP3,视频 2.文件打开方式 # 重定向 文件不存在 文件存在 r error 文件开头 w 相当于 > 创建 覆盖,删除以前的内 ...
- 2017"百度之星"程序设计大赛 - 初赛(A) 小C的倍数问题
谢谢帮忙刷访问量! 题解当然下考再发啦 答案为P-1的约数个数 // It is made by XZZ #include<cstdio> #include<algorithm> ...
- spring 属性文件加载接口---PropertySourceLoader
org.springframework.boot.config Interface PropertySourceLoader 实现类: PropertiesPropertySourceLoader, ...
- pyquery详细用法
python爬虫之PyQuery的基本使用 PyQuery库也是一个非常强大又灵活的网页解析库,如果你有前端开发经验的,都应该接触过jQuery,那么PyQuery就是你非常绝佳的选择,PyQue ...
- JAVA基础学习之路(十二)链表
定义链表的基本结构: class Link {//外部类 //内部类,只为链表类服务 private class Node {//定义节点类 private String data;//保存的数据 p ...
- 152.[LeetCode] Maximum Product Subarray
Given an integer array nums, find the contiguous subarray within an array (containing at least one n ...
- Halcon如何保存仿射变换矩阵
这里我们通过序列化来实现的,如下图,写到硬盘的HomMat2D_1内容和从硬盘里HomMat2D_2读出的内容一致,源代码在图片下方. Halcon源代码: hom_mat2d_identity (H ...
- ECharts模块化使用5分钟上手
什么是EChats? 一句话: 一个数据可视化(图表)Javascript框架,详细?移步这里,类似(推荐)的有 HighCharts,其他? 嗯,先看看吧-- 快速上手: 模块化单文件引入(推荐). ...
- 20162320MyOD重做版
博客说明 由于上次的MyOD.java没有得分,所以这次我重做了这个java,代码是自己完成的,请教了一些同学的思路.故补交一篇博客来说明我对每一步代码的编写的想法以及理解. 代码片段及理解 1.先创 ...
- 总结在Visual Studio Code运行node.js项目遇到的问题
一.cannot find module “lodash” 项目运行时出现以下错误: Error: Cannot find module 'lodash' at Function.Module._re ...