A

解法:DP+二分

dp[i]=max(dp[i],dp[j]+p[i].v)(i>j)

dp[i]表示建立i点之后能够获得的最大值

int n,M;

struct node

{

int l,v;

}p[1010];

int dp[1010];

bool cmp(node a,node b){

return a.l < b.l;

}

bool judge_oo(){

int Max = -1;

for(int i = 1;i <= n;i++) Max = max(Max,p[i].v);

if(Max >= M) return 1;

return 0;

}

bool judge_no(){

int sum = 0;

for(int i = 1;i <= n;i++) sum += p[i].v;

if(sum >= M) return 0;

return 1;

}

bool judge_DP(int L){

memset(dp,0,sizeof dp);

for(int i = 1;i <= n;i++){

for(int j = 0;j < i; j++){

if(p[i].l - p[j].l >= L){

dp[i] = max(dp[i],dp[j] + p[i].v);

}

}

}

int ML = 0;

for(int i = 1;i <= n;i++) ML = max(ML,dp[i]);

if(ML >= M) return 1;

return 0;

}

int solve(int L,int R){

while(L + 1 < R){

int mid = (L + R)/2;

if(judge_DP(mid)) L = mid;

else R = mid;

}

return L;

}

int main(int argc, char *argv[])

{

//freopen("data.in","r",stdin);

//freopen("data.out","w",stdout);

int T;

cin >> T;

while(T--){

cin >> n >> M;

for(int i = 1;i <= n;i ++)

cin >> p[i].l >> p[i].v;

if(judge_no()){

puts("-1");

continue;

}

if(judge_oo()){

puts("oo");

continue;

}

sort(p+1,p+n+1,cmp);

p[0].l = -100000000 , p[0].v = 0;

int L = 1 , R = p[n].l;

cout << solve(L,R) << endl;

}

return 0;

}

B

解法:模拟。字符串模拟

#include

//#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#define inf 0x3fffffff

#define INF 0x3f3f3f3f

#define lson l,m,rt<<1

#define rson m+1,r,rt<<1|1

#define LL long long

#define ULL unsigned long long

using namespace std;

int i,j;

int n,m;

int num_1,num_2;

int t;

int sum,ans,flag;

string s_1,s_2,s_3;

string sss;

string ss[10000];

string c;

mapq1;

mapq2;

int main()

{

cin>>t;

while(t--)

{

cin>>n>>c;

num_1=0;

for(i=0; i

{

cin>>sss;

ans=sss.find(".");

s_1=sss.substr(0,ans);

s_2=sss.substr(ans+1,sss.length());

if(s_2==c)

{

int ans_2=sss.find("(");

int ans_3=sss.find(")");

if((ans_2!=-1&&ans_2

{

// num_1++;

ss[num_1++]=sss.substr(0,ans_2);

// cout<

}

else if(ans_2==-1||ans_3==-1)

{

// num_1++;

ss[num_1++]=sss.substr(0,ans);

// cout<

}

}

}

for(i=0; i

{

// cout<

}

// cout<

for(i=0; i

{

q1[ss[i]]++;

}

for(i=0; i

{

if(q2[ss[i]]==0)

{

q2[ss[i]]=1;

if(q1[ss[i]]==1)

{

cout<

}

else

{

cout<

}

}

}

q1.clear();

q2.clear();

}

return 0;

}

C

解法:树状数组寻找逆序对+预处理

#include

#include

#include

#include

#include

using namespace std;

const int M = 200010;

long long ans[M + 10];

int G[M + 10],c[M + 10];

int Lowbit(int x)

{

return x & (-x);

}

void Insert(int x,int d)

{

while(x<=M){

c[x]+=d;

x+=Lowbit(x);

}

}

int Sum(int x)

{

int sum=0;

while(x>0){

sum+=c[x];

x-=Lowbit(x);

}

return sum;

}

void init()

{

memset(G,-1,sizeof G);

memset(ans,0,sizeof ans);

memset(c,0,sizeof c);

G[1] = 1;

for(int i = 2; i <= 200100;i++){

if(G[i] == -1){

for(int j = i;j <= 200100;j += i){

if(G[j] == -1){

G[j] = i;

}

}

}

}

for(int i=1;i<=200005;i++)

{

Insert(G[i],1);

ans[i] = ans[i-1] + (i-Sum(G[i]));

}

}

int main()

{

init();

int t;

cin>>t;

while(t--)

{

int n;

cin>>n;

cout<

}

return 0;

}

D

解法:模版题,最小覆盖圆

#include

#include

#include

#include

using namespace std;

const double eps=1e-8;

struct Point{

double x,y;

}p[505];

double dis(const Point &a,const Point &b)

{

return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));

}

Point circumcenter(const Point &a,const Point &b,const Point &c)

{ //返回三角形的外心

Point ret;

double a1=b.x-a.x,b1=b.y-a.y,c1=(a1*a1+b1*b1)/2;

double a2=c.x-a.x,b2=c.y-a.y,c2=(a2*a2+b2*b2)/2;

double d=a1*b2-a2*b1;

ret.x=a.x+(c1*b2-c2*b1)/d;

ret.y=a.y+(a1*c2-a2*c1)/d;

return ret;

}

void min_cover_circle(Point *p,int n,Point &c,double &r){ //c为圆心,r为半径

random_shuffle(p,p+n); //

c=p[0]; r=0;

for(int i=1;i

{

if(dis(p[i],c)>r+eps) //第一个点

{

c=p[i]; r=0;

for(int j=0;j

if(dis(p[j],c)>r+eps) //第二个点

{

c.x=(p[i].x+p[j].x)/2;

c.y=(p[i].y+p[j].y)/2;

r=dis(p[j],c);

for(int k=0;k

if(dis(p[k],c)>r+eps) //第三个点

{//求外接圆圆心,三点必不共线

c=circumcenter(p[i],p[j],p[k]);

r=dis(p[i],c);

}

}

}

}

}

int main(){

int n;

Point c;

double r;

int t;

cin>>t;

while(t--)

{

cin>>n;

for(int i=0; i

scanf("%lf%lf",&p[i].x,&p[i].y);

min_cover_circle(p,n,c,r);

printf("%.1f %.1f\n",c.x,c.y);

}

return 0;

}

时间: 11-29

江西理工大学c语言程序设计竞赛怎么备考,2015年江西理工大学C语言程序设计竞赛(高级组)...相关推荐

  1. 第十届蓝桥杯c语言试题,第十届蓝桥杯真题编程题1-7解析(高级组).pdf

    scratch 少儿编程第十届蓝桥杯真题 7 大家好 ~今天我们来讲解 scratch 蓝桥杯第十届编程大题的第七道题. 同样,这道题也是非常有难度的一道题.一起来看一下吧 解析: 女孩的程序 1.在 ...

  2. C语言考试题及答案(8),2015年计算机二级C语言测试题及答案(8)

    1: 请编写函数fun,对长度位7个字符的字符串,除首尾字符外,将其余5个字符按ascii码降序排列. 答案: void fun(char *s,int num) { char t; int I,j; ...

  3. 江西事业单位计算机专业知识真题,2015年江西事业单位考试计算机每日练习题(1月27日)...

    1.下列关于双核技术的叙述中,正确的是( ). A.双核就是指主板上有两个CPU B.双核是利用超线程技术实现的 C.双核就是指CPU上集成两个运算核心 D.主板上的一块芯片就是核心 [答案]C.解析 ...

  4. 2015年二级c语言真题及答案,2015年计算机二级C语言测试题及答案(4)

    基本输入输出及流程控制 1. #include main() { int a=1,b=3,c=5; if (c==a+b) printf("yes\n"); else printf ...

  5. c语言笔试题目,C语言考试题库及答案2015.doc

    C语言考试题库及答案2015.doc - PAGE 1 - C语言(共200题) 1.下面程序的输出是___D______ #include void main() { int k=11; print ...

  6. c语言程序竞赛,2015年江西理工大学C语言程序设计竞赛(初级组)

    JankTao相亲记 解法:排序 #include #include #include #include #include #include #include #include using names ...

  7. c语言oj竞选投票,Just oj 2018 C语言程序设计竞赛(高级组)H: CBT?

    H: CBT? 时间限制: 1 s      内存限制: 128 MB      提交 我的状态 题目描述 对于二叉树,如果这棵树的节点排布是按行从上到下,每行从左到右挨个放置,中间不会有空闲的节点. ...

  8. c语言程序设计李文杰,清华大学出版社-图书详情-《C语言程序设计(基于CDIO思想)》...

    计算机是执行程序的机器.在计算机问世之初,计算机使用者被迫直接采用机器指令代码编写程序.汇编语言的出现带来了些许方便,不过其改善程度相当有限.计算机高级程序设计语言的诞生和流行,大大方便了人们对计算机 ...

  9. c语言程序设计江宝钏实验六答案,《C语言程序设计》(江宝钏著)实验三答案.doc...

    <C语言程序设计>(江宝钏著)实验三答案 取木汹嘉蓝杀绥胶碘仑做工坝穗兔移猿花吾摧骑盏净苯哑亢剩洲挝己昭韦痉何路乃庆碑保隋呐湛肿腕观蓟匡踏蝉勋霸奄御笋组儒凶斡剖搽呐吼缘叉尝伯分铁屏沥芋忧柏 ...

最新文章

  1. 10篇论文带你入门深度学习图像分类(附下载)
  2. 计算机视觉——自动识别车牌简介
  3. c++ 输出二进制_Python之输入输出(input_output)
  4. nginx修改监听端口号8080_Nginx + Tomcat 配置
  5. 浅谈:MyBatis-Plus的CRUD与乐观锁,分页插件,逻辑删除
  6. SDNU 1093.DNA排序(水题)
  7. UVa 1368 - DNA Consensus String
  8. XenApp6 建立请求的连接时出错解决方法
  9. scala 异步调用_非阻塞异步Java 8和Scala的Try / Success / Failure
  10. linux查看xml文件的配置,Hibernate配置文件hibernate.cfg.xml的详细解释
  11. 关于JavaWeb项目加密的实现 2021-04-24
  12. Python中DataFrame去重
  13. 盒子浮动的重要性及对其它元素的影响
  14. 有序表的索引顺序结构查找次数分析
  15. java集群之间共享数据_多个JVM之间,数据共享的问题?
  16. EXPRESS语言与IFC体系
  17. mysql数据库url正确的是_下面关于连接mysql下的mydb数据库的url,编写正确的是()...
  18. 微信小程序 自定义picker封装成插件实现二级三级四级联动
  19. 双系统双硬盘安装(win7 64位+Ubuntu18.04)(固态硬盘+机械硬盘1T)小结
  20. 处理一份内心煎熬的工作有两种方法——只有一种是正确的

热门文章

  1. android o 小米note 3,小米 Note 3 MIUI 10 安卓 8.0 内测开启
  2. mysql 类型_MySQL-约束类型
  3. [一] 详细讲解: 线性表链式存储结构 中的 单链表; (数据结构和算法)
  4. java memcached 存储对象_memcached—向memcached中保存Java实体需注意的问题
  5. python中的zip()函数和map()函数
  6. ear包目录_Java中的JAR/EAR/WAR包的文件夹结构说明(转)
  7. c mysql 内存泄露_c代码连接mysql数据库内存泄露的问题
  8. linux mount挂载命令(将分区挂接到Linux的一个文件夹下,从而将分区和该目录联系起来)
  9. 网页HTTP协议 get和post请求区别?(HTTP中Get、Post、Put与Delete的区别)
  10. 【记忆断层、记忆裂痕】