NOIP蒟蒻的//专栏
一只NOIp的蒟蒻,可能会写以下内容: # 计算机和程序设计 # 题解 # 物理(虽然并没过B卷) # 各种神奇的练习题
文号D907192
701
0
收藏
编辑文章

洛谷 P1003 [NOIP 2011 提高组] 铺地毯 题解

上海市华二陆家嘴分校,栖霞路34号

中文摘要

简简单单的一个题解,欢迎交流,前进!

关键词

算法算法竞赛C语言洛谷算法题编程计算机科学noip

#include <stdio.h>

#include<stdlib.h>

struct point {

long x,y,xl,yl,count ;

struct point * next;

};

int main() {

long all=0;

long ans=-1;

struct point old,start;

struct point target;

scanf("%ld",&all);

struct point* new =(struct point *)malloc(sizeof(struct point));

start=new ;

for(int a=1;a<=all;a++){

scanf("%ld",&(new->x));

scanf("%ld",&(new->y));

scanf("%ld",&(new->xl));

scanf("%ld",&(new->yl));

new->count=a;

old =new;

new =(struct point *)malloc(sizeof(struct point));

old->next=new;

}

old->next=NULL;

free(new);

scanf("%ld",&target.x);

scanf("%ld",&target.y);

do{

if(target.x>=start->x&&target.x<=(start->xl+start->x)&&target.y>=start->y&&target.y<=(start->yl+start->y)){

ans =start->count;

}

old = start;

start=start->next;

free(old);

}while(start!=NULL);

printf("%ld",ans);

return 0;

}


0
还没有人评论哦~~

想参与大家的讨论?现在就 登录 或者 注册

主体信息
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:浙江
 内容统计
2025年03月
5 篇
2023年
2 篇
2022年
3 篇
2021年
2 篇
2020年
5 篇
2019年
2 篇
ID: {{user.uid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
回复
设为精选取消精选
评学术分
鼓励
编辑
查看历史
通过审核
移动文章
加入收藏取消收藏
退修或删除
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}
回复
加入收藏取消收藏