CONTEST45 呵呵呵呵呵
题目质量差评!为什么不给数据范围!
A.乘积最大3
题目:http://dev.luogu.org/problem/show?pid=2172
题解:sb题,均值定理。
代码:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 10000000
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
ll n,m,tmp,a[maxn];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
n=read();m=read();
for1(i,m)a[i]=n/m;
tmp=n-(n/m)*m;
for3(i,m,m-tmp+)a[i]++;
for1(i,m-)printf("%lld ",a[i]);
printf("%lld\n",a[m]);
return ;
}
B.刮油漆
题目:http://dev.luogu.org/problem/show?pid=U155
题解:先差分算出每个点的高度,然后单调栈搞掉。
不知道哪写残了一直WA,没AK真不爽。。。
代码:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+1000
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
int n,ans,mx,top,a[maxn],b[maxn],sta[maxn];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
n=read();
for1(i,n)
{
int x=read(),y=read();
a[x]++,a[y+]--;
if(y+>mx)mx=y+;
}
for1(i,mx)b[i]=b[i-]+a[i];
ans=mx;
sta[top=]=;
for1(i,mx)
{
while(top>&&sta[top]>b[i])top--;
if(sta[top]==b[i])ans--;else sta[++top]=b[i];
}
printf("%d\n",ans);
return ;
}
C.选学霸
题目:http://dev.luogu.org/problem/show?pid=2170
题解:并查集完了之后背包,怎么昨天一天做了两道这种题?
代码:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define inf 1000000000
#define maxn 1000000+1000
#define maxm 500+100
#define eps 1e-10
#define ll long long
#define pa pair<int,int>
#define for0(i,n) for(int i=0;i<=(n);i++)
#define for1(i,n) for(int i=1;i<=(n);i++)
#define for2(i,x,y) for(int i=(x);i<=(y);i++)
#define for3(i,x,y) for(int i=(x);i>=(y);i--)
#define mod 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}
return x*f;
}
int n,m,k,ans,tot,sum,fa[maxn],a[maxn],s[maxn];
bool f[maxn];
inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
n=read();k=read();m=read();
for1(i,n)fa[i]=i;
for1(i,m)
{
int x=find(read()),y=find(read());
if(x!=y)fa[x]=y;
}
for1(i,n)s[find(i)]++;
for1(i,n)if(s[i])a[++tot]=s[i];
f[]=;
for1(i,tot)
{
for3(j,sum,)
if(f[j])f[j+a[i]]=;
sum+=a[i];
}
for3(i,k,)if(f[i]){ans=i;break;}
for2(i,k,n)if(f[i]){if(abs(i-k)<k-ans)ans=i;break;}
printf("%d\n",ans);
return ;
}
这场比赛没有好好做,因为看起来都是些sb题。。。
CONTEST45 呵呵呵呵呵的更多相关文章
- COJN 0486 800401反质数 呵呵呵呵呵
800401反质数 难度级别:A: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 将正整数 x 的约数个数表示为 g(x).例如,g(1)=1 ...
- CSDN的博客搜索功能不又给力了呵呵呵呵
不得不说,CSDN博客的搜索功能是在太弱了.而且一直都很弱,以至于我每次想在自己博客上找自己发的文章都变得那么难.做一个搜索博客内文章的功能没有那么难吧? 还是说CSDN已经放弃了博客这一块了? 我发 ...
- 呵呵呵呵。。。系统还原了,终于可以用IE登陆百度了
原文发布时间为:2009-12-19 -- 来源于本人的百度文章 [由搬家工具导入] 呵呵呵呵。。。今天终于有时间把系统还原了,终于可以用IE登陆百度了
- sycCMS PHP V1.0---呵呵呵呵呵
闲的无聊,随便找了份代码看了看. //search.php 第17行 第49行 ...... $keyword=SafeRequest("keyword","post&q ...
- 用.NET MVC实现长轮询,与jQuery.AJAX即时双向通信
两周前用长轮询做了一个Chat,并移植到了Azure,还写了篇博客http://www.cnblogs.com/indream/p/3187540.html,让大家帮忙测试. 首先感谢300位注册用户 ...
- java笔记——Java关键字static、final使用小结
static 1. static变量 按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的 ...
- p2p tcp nat 原理图+源码(原创)
现今网上p2p的 udp nat穿透 文章 多如牛毛, p2p tcp nat的文章寥寥无几 ,up主研究了几天 终于有所收获,特来向大家分享,请大家多多支持! 1.首先你要有台外网服务器 或者 电信 ...
- 【转】如何使用VS 2013发布一个可以在Windows XP中独立运行的可执行文件
问题描述: 用VS2013写好一个程序,在本机上运行一切正常.但是如果直接把exe文件放到另一台机器上用,则会出现: Windows XP:不是一个正常的win32程序 Window 7:缺少msvc ...
- 一般企业网站,电商可以完全可以水平拓展的lanmp系统架构
本来不打算把所有的架构方案和基础技术写出,毕竟是吃饭的家伙事,拿这套东西去面试完全可以对付只做过中小网站的经验的开发面试人员,但是我也是从别人的博客和文章学习和实践出来的 如果你没有基础的linux一 ...
随机推荐
- UVA 11636 - Hello World! 水
水题,贪心,dp都随意 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,ple ...
- hadoop2.2.0的ha分布式集群搭建
hadoop2.2.0 ha集群搭建 使用的文件如下: jdk-6u45-linux-x64.bin hadoop-2.2.0.x86_64.tar zookeeper-3.4.5. ...
- JS(六)
没有视频看了,心里有点慌啊,像这种每天都会灌输很多知识的学习方式,我觉得提前预习真的是有奇效,不然不容易跟上老师的思维. 1.发送验证码:简单 <!DOCTYPE html> <ht ...
- maven 命令小记
mvn help:system mvn clean compile mvn clean test 测试 mvn clean package ...
- 继承PictureBox显示GIF的自定义控件实现
处理GIF部分 using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
- [React Testing] Conditional className with Shallow Rendering
Often our components have output that shows differently depending on the props it is given; in this ...
- USB HID Report Descriptor 报告描述符详解
Report descriptors are composed of pieces of information. Each piece of information is called an Ite ...
- RedHat下GCC及G++的安装
GCC的安装: 切换到安装光盘目录下: #mount /dev/cdrom /mnt/cdrom #cd /mnt/cdrom 安装GCC依赖的*rpm程序,必须按照顺序依次执行: #rpm - ...
- statusBarOrientation设备状态
判断设备的状态 UIApplication* app = [UIApplication sharedApplication]; // 判断设备方向状态,做响应的操作 if(app.statusBa ...
- 最新版 CocoaPods 的安装流程(包括EI Capitan版)
1.移除现有Ruby默认源 $gem sources --remove https://rubygems.org/ 2.使用新的源 $gem sources -a https://ruby.taoba ...