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一 ...
随机推荐
- HDU_2053
Problem Description There are many lamps in a line. All of them are off at first. A series of operat ...
- Shell的输入输出
通过使用read命令,可以实现从终端中输入内容后输出或执行运算 #!/bin/bash #Author: blacksonny #Copyright (c) #Script follows here: ...
- SecureCRT7.3和SecureFX7.3的MAC下破解
破解脚本:http://files.cnblogs.com/files/jieyuefeng/SecureCRTFX_mac_crack.zip 破解方法: sudo perl ~/Downloads ...
- JAXB--学习2
一.Jaxb处理java对象和xml之间转换常用的annotation有: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccesso ...
- Struts+Spring搭建
前言 本文以Tomcat为j2ee容器,数据库为Sqlserver2005进行说明.Struts版本为2.3.15.3,Spring版本为3.2.5 Spring简介 Spring也是appache下 ...
- ionic学习教程地址梳理
Ionic是一个新的.可以使用HTML5构建混合移动应用的用户界面框架,它自称为是"本地与HTML5的结合".该框架提供了很多基本的移动用户界面范例,例如像列表(lists).标签 ...
- 一、Solr综述
什么是Solr搜索 我们经常会用到搜索功能,所以也比较熟悉,这里就简单的介绍一下搜索的原理. 当然只是介绍solr的原理,并不是搜索引擎的原理,那会更复杂. 流程图 这是一个非常简单的流程图: Use ...
- Redis配置不当可导致服务器被控制,已有多个网站受到影响 #通用程序安全预警#
文章出自:http://news.wooyun.org/6e6c384f2f613661377257644b346c6f75446f4c77413d3d 符合预警中“Redis服务配置不当”条件的服务 ...
- (一)《Java编程思想》学习——按位运算符、移位运算符
(第三章) (一)按位运算符 按位逻辑运算符有: “与”(AND) & 1&1=1;1&0=0;0&0=0 “或”(OR) | 1|1=1;1|0=1;0 ...
- sql server代理中作业执行SSIS包失败
RT,执行失败了,总是只提示一句“以xxxx用户身份执行失败”,很难找原因. 引用 http://bbs.csdn.net/topics/300059148 Sql2005如何用dtexec运行ssi ...