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) ...
随机推荐
- javascript中ajax post实例详解
一,原生态的XMLHttpRequest 代码如下 复制代码 <script language="javascript"> function savei ...
- File.Create创建文件后,需要释放资源
if (!File.Exists(SavePath)) { File.Create(SavePath).Close(); }
- 以莫泰的形式进行页面转换(传值用block)
1.在第一个页面进入第二个页面可以使用莫泰的方式 在第一个页面包含第二个页面的头文件#import "FirstViewController.h"#import "Vie ...
- 【学习笔记】【C语言】类型说明符
1. short和long 1> short和long可以提供不同长度的整型数,也就是可以改变整型数的取值范围.在64bit编译器环境下,int占用4个字节(32bit),取值范围是-231~2 ...
- 银联接口测试——详细(JAVA)
准备材料 1.注册账号 https://open.unionpay.com/ajweb/register?locale=zh_CN 2.▼登录账号 -->帮助中心--> 下载,选择网关支付 ...
- 4月12日学习笔记——jQuery操作属性和样式
区分 DOM 属性和元素属性 <img src="images/image.1.jpg" id="hibiscus" alt="Hibiscus ...
- 《JavaScript高级程序设计》心得笔记-----第一篇章
第一章 JavaScript由ECMAScript.DOM.BOM组成.其中BOM功能在HTML5中有了正式的规范,使BOM的兼容性越来越高. 第二章 1.<script>属性中的asyn ...
- 杭电2034——人见人爱A-B
#include <stdio.h> #include <algorithm> using namespace std; int main () { int a[110],b[ ...
- OpenGL第12-14讲小结
首先要为自己为什么没有写第10讲的控制3D场景和第11讲的红旗飘飘呢?因为没看啊~哈哈哈,而且我尝试着运行红旗飘飘的时候电脑蓝屏了(可能不是它的锅),暂时跳过了. 恩,12到14主要了解了这么些东西, ...
- javascript给不能修改的函数增加额外处理的方法
不知道是否可行,但姑且google之. 查看到相关的stack overflow(堆栈溢出)帖子:http://stackoverflow.com/questions/1659219/add-to-a ...