animals

Separate the Animals

五迷三道 提交于 2020-02-09 00:03:18
There are some animals in a zoo which can be described as a grid with N rows and M columns. Your task is to place some obstacles so that no pairs of animals can reach each other. Two animals can reach each other if and only if their cells are 4-connected. For example, in Figure 1, the central blue cell can be reached by the four red cells, and cannot be reached by the other four white cells. Figure 1 What is more, you must put obstacles in exactly K cells, which are 4-connected and form exactly H holes. Here a hole is defined as a 4-connected part with finitely many open cells while the zoo is

Python基本数据类型、容器、函数、类

☆樱花仙子☆ 提交于 2020-02-01 19:53:34
一、基本数据类型 与大多数语言一样,Python有许多基本类型,也叫python内置的数据类型,包括整数,浮点数,布尔值和字符串。这些数据类型的行为方式与其他编程语言相似。 Numbers(数字类型) :代表的是整数和浮点数,它原理与其他语言相同: x = 3 print(type(x)) # Prints "<class 'int'>" print(x) # Prints "3" print(x + 1) # Addition; prints "4" print(x - 1) # Subtraction; prints "2" print(x * 2) # Multiplication; prints "6" print(x ** 2) # Exponentiation; prints "9" x += 1 print(x) # Prints "4" x *= 2 print(x) # Prints "8" y = 2.5 print(type(y)) # Prints "<class 'float'>" print(y, y + 1, y * 2, y ** 2) # Prints "2.5 3.5 5.0 6.25" 注意,与许多语言不同,Python没有一元增量( x+ )或递减( x- )运算符。 (Python还有用于复数的内置类型) Booleans(布尔类型) :

抽象类的构造函数

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-27 09:40:25
先通过一个实类继承来理解: Class Animals{ public Animals(){} public void eat(); } Class Dog extends Animals{ //super();不写父类构造的情况下,相当于会默认有个super(),调用父类的空参构造 pubilc Dog(){} @Override public void eat(){ print(“狗吃肉”); } } 在有此继承关系的情况下,如果对dog进行实例化即new dog()操作,那么一定会调用new Animals()操作,这时候就需要调用animals的构造函数后才能调用子类的构造函数。 这样就好理解了,抽象类也是可以继承的,而继承后就会有子类的实例化的操作,而如果抽象类中没有构造方法,那继承此抽象类的子类将无法实例化。 来源: CSDN 作者: Victoria Coleone 链接: https://blog.csdn.net/qq_33581012/article/details/103846236

BeanUtils StringUtils Validation

给你一囗甜甜゛ 提交于 2019-12-20 07:54:05
package com . example . demo . BeanUtils ; import com . example . demo . dao . Animals ; import org . apache . commons . beanutils . BeanUtils ; import org . apache . commons . beanutils . ConvertUtils ; import org . junit . Test ; import java . util . Date ; import java . util . HashMap ; import java . util . Map ; /** * @author shuyue.guo * @date 2019/12/16 */ public class test { public void test1 ( ) throws Exception { Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "name" , "tuantuan" ) ; map . put ( "age" , 3 ) ; map . put ( "color" , "black" ) ; map . put

python学习-64 面向对象三大特性----继承1

◇◆丶佛笑我妖孽 提交于 2019-12-02 22:52:22
面向对象三大特性 1.三大特性? 继承,多态,封装 2.什么是继承? 类的继承和现实生活中的父与子,继承关系是一样的,父类为基类。 python中的类继承分为:单继承和多继承 3.举例说明 class Dad: money = 100 def __init__(self,name): self.name =name print(name) def hit(self): print('%s 正在打孩子' %self.name) class Son(Dad): pass s1 = Son('abc') print(Son.money) s1.hit() 运行结果: abc 100 abc 正在打孩子 Process finished with exit code 0 4.什么时候用继承? ----当类之间有显著不同,并且较小的类是较大的类所需要的组件时,用组合比较好。 ----当类之间有很多相同的功能,提取这些共同的功能做成基类,用继承比较好。 class Animals: def eat(self,name): print('%s 正在吃'%self.name) def drink(self,name): print('%s 正在喝'%self.name) class Cat(Animals): def __init__(self,name): self.name = name

XML

时光毁灭记忆、已成空白 提交于 2019-11-29 03:28:12
XML(EXtensible Markup Language) 可扩展标记语言,它的作用是传输和保存数据,可以自定义标签。 1、DTD(文档类型定义),对XML文件的格式进行定义。 (1)内部DTD,在XML文档内,只对当前XML有效。 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE animals[ <!ELEMENT animals (animal+)> <!ELEMENT animal (name,color,favorite)> <!ELEMENT animal id CDATA #REQUIRED> <!ELEMENT name (#PCDATA)>//不能再加其他标签 <!ELEMENT color (#PCDATA)> <!ELEMENT faxorite (#PCDATA)> ]> <animals> <animal id="1"> <name>rabbit</name> <color>white</color> <favorite>胡萝卜</favorite> </animal> <animal id="2"> <name>sheep</name> <color>black</color> <favoriate>青草</favoriate> </animal> </animals> 知识点总结: (1) <?xml