栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

201912-2 回收站选址

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

201912-2 回收站选址

文章目录

201912-2 回收站选址

1. 题目介绍2. Python代码3.测试结果:

201912-2 回收站选址 1. 题目介绍

本题网址:http://118.190.20.162/view.page?gpid=T99本题截图:



2. Python代码

n = int(input()) # 已查明的垃圾点个数
I = [0]*n # 垃圾点的坐标集合
H = [] # 回收站坐标
C = [] # 得分集合
for i in range(n):
    I[i] = list(map(int, input().split()))
for i in range(n):
    x=I[i][0]
    y=I[i][1]
    if [x+1,y] in I and [x,y+1] in I and [x-1,y] in I and [x,y-1] in I:
        H.extend([I[i]])
for h in H:
    count = 0 # 得分初始为0
    x = h[0]
    y = h[1] 
    if [x+1,y+1] in I:       
        count += 1
    if [x+1,y-1] in I:
        count += 1
    if [x-1,y-1] in I:
        count += 1
    if [x-1,y+1] in I:
        count += 1
    C.extend([count])    
print(C.count(0))
print(C.count(1))
print(C.count(2))
print(C.count(3))
print(C.count(4))
3.测试结果:

总结:小白刚刚接触csp,若代码算法关于简单,过于暴力望谅解

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/757897.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号