package c2021;
import java.util.HashSet;
public class zhixian{
public static void main(String[] args) {
System.out.println("hello1");
int x = 20;
int y = 21;
HashSet<zx> zxs = new HashSet<>();
int sum;
System.out.println("hello2");
for (int x1 = 0; x1 < x; x1++) {
for (int y1 = 0; y1 < y; y1++) {
for (int x2 = 0; x2 < x; x2++) {
for (int y2 = 0; y2 < y; y2++) {
if (x1 != x2 && y1 != y2) {
zxs.add(new zx(x2 - x1, y2 - y1, x2 * y1 - x1 * y2));
}
}
}
}
}
sum = zxs.size() + x + y;
System.out.println("hello3");
System.out.println(sum);
}
}
class zx{
int fenmu;
int fenzi1;
int fenzi2;
public zx(int fenmu, int fenzi1, int fenzi2) {
// TODO Auto-generated constructor stub
this.fenmu = fenmu;
this.fenzi1 = fenzi1;
this.fenzi2 = fenzi2;
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return 1;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
zx tempZx = (zx)obj;
if (this.fenzi1 * tempZx.fenmu == this.fenmu * tempZx.fenzi1 && this.fenzi2 * tempZx.fenmu == this.fenmu * tempZx.fenzi2) {
return true;
}else {
return false;
}
}
}
简结代码解2021年蓝桥杯A组省赛第二题
于 2022-03-10 21:47:47 首次发布