二分 题目 压缩打包 Special Judge? 不不不 当然不是
http://noi.openjudge.cn/ch0111/
No | 题目 | 分数 | |
01 | 查找最接近的元素 | 10 | 3176 |
02 | 二分法求函数的零点 | 10 | 2181 |
03 | 矩形分割 | 10 | 1420 |
04 | 网线主管 | 10 | 1648 |
05 | 派 | 10 | 1581 |
06 | 月度开销 | 10 | 1449 |
07 | 和为给定数 | 10 | 1906 |
08 | 不重复地输出数 | 10 | 1790 |
09 | 膨胀的木棍 | 10 | 768 |
10 | 河中跳房子 | 10 | 2027 |
------------------------------萌萌的分割线------------------------------
T1
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define INF 0x3f3f3f3f
using namespace std; int a[],ans,flag,M,N; int erfen(int x){
int l=,r=N;
while(r-l>){
int mid=l+(r-l)/;
if(a[mid]>=x){
r=mid;
}
else{
l=mid;
}
}
int pos=,cha=INF;
for(int i=l-<?:l-;i<=r+;i++){
if(abs(a[i]-x)<cha){
pos=i;
cha=abs(a[i]-x);
}
}
return a[pos];
} int main(){
// freopen("01.in","r",stdin); memset(a,0x3f,sizeof(a));
scanf("%d",&N);
for(int i=;i<=N;i++){scanf("%d",&a[i]);}
scanf("%d",&M);
while(M--){
int x;scanf("%d",&x);
printf("%d\n",erfen(x));
}
fclose(stdin);fclose(stdout);return ;
}要恶心地多判断几次
T2
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define eps 1e-9
using namespace std; int a[],N; double cal(double x){
return x*x*x*x*x-15.0*x*x*x*x+85.0*x*x*x-225.0*x*x+274.0*x-121.0;
} double erfen(double l,double r){
while(r-l>eps){
double mid=(l+r)/2.0;
if(cal(mid)>=){
l=mid;
}
else {
r=mid;
}
}
return l;
} int main(){
// freopen("01.in","r",stdin); printf("%.6f",erfen(1.5,2.4)); fclose(stdin);fclose(stdout);return ;
}l和r别弄反了
T3
T4
T5
T6
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define INF 0x3f3f3f3f
using namespace std; int a[],M,N,kkk,mx; int solve(){
int ans=,flag=;
for(int i=;i<=N+;i++){
int x=a[i];
if(flag+x>M) flag=x,++ans;
else flag+=x;
}
return ans;
} void erfen(){
int cnt=;
int ans=INF;
int l=mx,r=INF;
while(cnt++< && l!=r){
M=(l+r)/;
int k=solve();
if(k>kkk){
l=M;
}
else{
r=M;
}
if(k<=kkk) ans=min(ans,M);
// cout<<k<<" "<<l<<" "<<r<<endl;
}
cout<<ans;
} int main(){
// freopen("01.in","r",stdin); memset(a,0x3f,sizeof(a));
scanf("%d%d",&N,&kkk);
for(int i=;i<=N;i++){scanf("%d",&a[i]);mx=max(mx,a[i]);} erfen(); fclose(stdin);fclose(stdout);return ;
}这件事告诉我们,一定要写随机数据
随机数据查错非常给力
T7
T8
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define INF 0x3f3f3f3f
using namespace std; int a[],N; int main(){
// freopen("01.in","r",stdin); scanf("%d",&N);
for(int i=;i<=N;i++) scanf("%d",&a[i]);
sort(a+,a+N+);
for(int i=;i<=N;i++){
if(a[i]!=a[i+]) printf("%d ",a[i]);
} fclose(stdin);fclose(stdout);return ;
}我选择偷懒,吐舌~
T9
T10
噜噜噜~
二分 题目 压缩打包 Special Judge? 不不不 当然不是的更多相关文章
- csu oj 1344: Special Judge
Description Given a positive integer n, find two non-negative integers a, b such that a2 + b2 = n. I ...
- 如何给LOJ补全special judge
首先你要会写一个叫$data.yml$的东西, 这里面记录了这道题的$subtask$计分策略 也告诉了评测姬这道题是提交答案还是$spj$还是交互题 那么,$YAML$语言是啥啊? 别问我,我也不会 ...
- Special Judge Ⅱ
Problem Description Q:什么是 Special Judge,Special Judge 的题目有什么不同? A:一个题目可以接受多种正确答案,即有多组解的时候,题目就必须被 Spe ...
- 【教程】如何正确的写一个Lemon/Cena的SPJ(special judge)
转自:http://www.cnblogs.com/chouti/p/5752819.html Special Judge:当正确的输出结果不唯一的时候需要的自定义校验器 首先有个框架 #includ ...
- 服务端生成word并压缩打包下载
所需工具 phpwrod 库 php_zip 扩展 下载phpword库,放到类加载路径. 安装php_zip扩展 下载地址 http://pecl.php.net/package/zip linux ...
- Linux中的文件压缩,打包和备份命令
压缩解压命令 gzip 文件 -c : 将压缩数据输出到屏幕,可用来重定向 -v 显示压缩比等信息 -d 解压参数 -t 用来检验一个压缩文件的一致性看看档案有没错 -数字 : 压 ...
- C# 压缩打包文件下载
C# 压缩打包文件下载 public class MyNameTransfom : ICSharpCode.SharpZipLib.Core.INameTransform { #region INam ...
- [拾 得] zip gzip bzip2 & tar 压缩/打包 四大金刚
坚持知识分享,该文章由Alopex编著, 转载请注明源地址: http://www.cnblogs.com/alopex/ 索引: 介绍压缩和打包 gzip bzip2 zip 的基本使用 gz ...
- mvn项目压缩打包
通常情况下,maven打包结果为jar或war包.如果需要一并打包配置文件等参数,通过resources配置指定需要打包的文件参数,如下示例: <project> ... <!-- ...
随机推荐
- 虚拟机NAT网络配置
今天虚拟机NAT模式配置网络遇到一个奇葩问题.主机能ping同虚拟机时,虚拟机不能ping同主机.相反虚拟机ping通主机时,主机ping不通虚拟机. 最后花了一个小时,终于可以互通了,做一个记录: ...
- C#操作access和SQL server数据库代码实例
在C#的学习中,操作数据库是比较常用的技术,而access和sql server 数据库的操作却有着不同.那么,有哪些不同呢? 首先,需要引用不同的类.因为有着不同的数据引擎. access:usin ...
- Redis启动多端口、运行多实例
默认Redis程序安装在/usr/local/redis目录下: 配置文件:/usr/local/redis/redis.conf,该配置文件中配置的端口为默认端口:6379: Redis的启动命令路 ...
- JS Date.parse() 函数详解
Date.parse()函数用于分析一个包含日期的字符串,并返回该日期与 1970 年 1 月 1 日午夜之间相差的毫秒数. 该函数属于Date对象,所有主流浏览器均支持该函数. 语法 Date.pa ...
- 得静下心来看python了。
陆陆续续看了些python爬虫的相关知识.今天找到了这篇博客不错就看这个,明天看到那个又很好又跑去看那个. 来来回回耽误不少时间.接下来不能再这样了,老老实实就看xlzd.me博客和Python实战: ...
- 关于 android 的setOnItemClickListener 和 setOnItemLongClickListener 同时触发的解决方法
关于 android 的setOnItemClickListener 和 setOnItemLongClickListener 同时触发的解决方法. 其实方法也是很简单 的主要 setOnItemLo ...
- 【转】Caffe初试(八)Blob,Layer和Net以及对应配置文件的编写
深度网络(net)是一个组合模型,它由许多相互连接的层(layers)组合而成.Caffe就是组建深度网络的这样一种工具,它按照一定的策略,一层一层的搭建出自己的模型.它将所有的信息数据定义为blob ...
- IOS进阶之WKWebView
前言 Xcode8发布以后,编译器开始不支持IOS7,所以很多应用在适配IOS10之后都不在适配IOS7了,其中包括了很多大公司,网易新闻,滴滴出行等.因此,我们公司的应用也打算淘汰IOS7. 支持到 ...
- javascript学习笔记之array.sort
arrayName.sort()方法: 功能是实现排序(按ascii编码或按数字大小),可无参或有参使用,无参时默认升序排列.有参时可实现升序或降序排列,参数必须是具有返回值的方法,当方法表达式大于0 ...
- 在c#中的TextBox响应回车键发出“咚”的一声解决方法
在Win7系统的VS2012下的Form中,响应TextBox的KeyDown事件后,当按下回车键时发出"咚"的一声,百度后得到一下这样一个说法: 这是对于 windows 窗口标 ...