nenu contest
http://vjudge.net/vjudge/contest/view.action?cid=54393#overview
A n^2能过 对第二个n我二分了一下,快了一点点,nlogn
#include<cstdio>
#include<algorithm>
using namespace std;
double judge[];
int main(){
for(int i=;i<;i++){
judge[i]=i*;
}
double now;
int n,s;
while(~scanf("%d%d",&n,&s)){
int sum=;
for(int i=;i<n;i++){
scanf("%lf",&now);
int L=lower_bound(judge,judge+,now)-judge;
if(judge[L]>now) L--;
if(judge[L]<=now&&now<=judge[L]+) sum++;
}
printf("%.1f\n",sum*(+0.2*s));
}
return ;
}
A LEE的on的方法也很值得借鉴,竟然比我二分的慢,不知为何,数据小吧
#include<cstdio>
const double eps = 1e-;
int main() {
int n, s, cnt;
double t;
while (~scanf("%d%d", &n, &s)) {
cnt = ;
while (n--) {
scanf("%lf", &t);
int T = int(t);
if (T % < || (T % == && (t-T) < eps)) {
cnt++;
}
}
printf("%.1f\n", cnt*( + 0.2*s));
}
return ;
}
B %X scanf printf 16进制输入输出
#include<cstdio>
#include<cstring>
const int M=;
char op[M];
int main(){
int t,sa,sb;
while(~scanf("%d",&t)){
while(t--){
scanf("%X%X",&sa,&sb);
getchar();
gets(op);
int lp=strlen(op);
for(int i=;i<lp;i++){
if(op[i]==''){
if(op[i+]=='A'){
sa+=sb;
}
else{
sb+=sa;
}
i+=;
}
else if(op[i]=='F'){
if(op[i+]=='A'){
sa+=sa;
}
else{
sb+=sb;
}
i+=;
}
}
printf("%X %X\n",sa,sb);
}
}
return ;
}
C 比赛时n^2logn 900ms压线过,事实上nlogn就行了
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#define mt(a,b) memset(a,b,sizeof(a))
using namespace std;
const int M=;
class UnionFindSet { //并查集
int par[M];
public:
void init() {
mt(par,-);
}
int getroot(int x) {
int i=x,j=x,temp;
while(par[i]>=) i=par[i];
while(j!=i) {
temp=par[j];
par[j]=i;
j=temp;
}
return i;
}
bool unite(int x,int y) {
int p=getroot(x);
int q=getroot(y);
if(p==q)return false;
if(par[p]>par[q]) {
par[q]+=par[p];
par[p]=q;
} else {
par[p]+=par[q];
par[q]=p;
}
return true;
}
}gx;
map<string,int> mp;
string str;
int main(){
int n,m;
char op[];
while(~scanf("%d",&n)){
bool flag=false;
gx.init();
mp.clear();
for(int i=;i<=n;i++){
scanf("%d",&m);
while(m--){
flag=true;
scanf("%s",op);
str=(string)op;
if(!mp[str]){
mp[str]=i;
}
else{
gx.unite(mp[str],i);
}
}
}
if(!flag){
printf("%d\n",n);
continue;
}
int ans=;
for(int i=;i<=n;i++){
if(i==gx.getroot(i)) ans++;
}
printf("%d\n",ans-);
}
return ;
}
I n^2能过400ms on单调队列62ms
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int M=;
int a[M],b[M];
int main(){
int n,m;
while(~scanf("%d%d",&n,&m)){
for(int i=;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=;i<m;i++){
scanf("%d",&b[i]);
}
int la=,lb=,ans=1e9;
while(la!=n&&lb!=m){
ans=min(ans,abs(a[la]-b[lb]));
if(a[la]>b[lb]) lb++;
else la++;
}
printf("%d\n",ans);
}
return ;
}
J on 水题
#include<cstdio>
typedef __int64 LL;
const int M=;
char a[M][];
int main(){
int n;
while(~scanf("%d",&n)){
for(int i=;i<n;i++){
scanf("%s",a[i]);
}
LL ans=;
LL sum=;
for(int i=n-;i>=;i--){
if(a[i][]=='W') ans+=sum;
else sum++;
}
printf("%I64d\n",ans);
}
return ;
}
nenu contest的更多相关文章
- nenu contest3 The 5th Zhejiang Provincial Collegiate Programming Contest
ZOJ Problem Set - 2965 Accurately Say "CocaCola"! http://acm.zju.edu.cn/onlinejudge/showP ...
- 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) ...
随机推荐
- Hadoop集群“WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable”解决办法
Hadoop集群部署完成后,经常会提示 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platfo ...
- 程序代码创建IISWEB站点
#region 新建立一个IISWEB站点 ///<summary> ///添加一个站点 ///</summary> public string CreateWebSite() ...
- UI1_ViewController视图切换及Appdelegate
// // ThirdViewController.h // UI1_ViewController视图切换及Appdelegate // // Created by zhangxueming on 1 ...
- 异常getaddrinfo enotfound
在看NodeJS开发指南这本书时,书中的一个例子,讲解http.request的.代码如下: var http = require('http'); var querystring = require ...
- 分享10 个超酷的 HTML5/CSS3 应用及源码
1.HTML5视频破碎重组特效,强大视觉冲击 HTML5视频播放器很多,但是HTML5视频特效还是很少见的,这款HTML5视频破碎重组特效非常刺激,给人强大的视觉冲击.点击视频任意地方,HTML5将会 ...
- Integer类的装箱和拆箱到底是怎样实现的?
先解释一下装箱和拆箱: 装箱就是 自动将基本数据类型转换为包装器类型:拆箱就是 自动将包装器类型转换为基本数据类型. 下表是基本数据类型对应的包装器类型: int(4字节) Integer byt ...
- 3D球状标签云(兼容IE8)
看见一个很有趣的标签云,3D球状,兼容 IE 8,亲测可用!其他版本没有测试.觉得挺有意思就拿来记录下来,学习学习,本文下方会放出我看的文章地址,先看一下效果: 接下来是代码,html + css + ...
- module graceful-fs for npm
问题: 今天使用hexo时发现错误,hexo:command not found.于是重新安装hexo.但是在安装好npm后,却发现运行 npm 出现错误,没有找到模块graceful-fs,在纠结了 ...
- getMeasuredHeight() 与 getHeight() 的区别
http://www.cnblogs.com/x-dev/p/3767538.html?utm_source=tuicool&utm_medium=referral public final ...
- [大牛翻译系列]Hadoop(19)MapReduce 文件处理:基于压缩的高效存储(二)
5.2 基于压缩的高效存储(续) (仅包括技术27) 技术27 在MapReduce,Hive和Pig中使用可分块的LZOP 如果一个文本文件即使经过压缩后仍然比HDFS的块的大小要大,就需要考虑选择 ...