Pony.ai 笔试
第一题 暴力AC
import java.util.Arrays; import java.util.Scanner; public class Main { static int[] check(int[] a) { int n = a.length; int[] c = new int[n]; c[0] = a[0]; int d = a[1] - a[0]; for (int i = 1; i < n; i++) { c[i] = c[i - 1] + d; if (c[i] < 0) { return null; } if (c[i] % a[i] > 0) { return null; } int t = c[i] / a[i]; if ((t & (t - 1)) != 0) { return null; } } return c; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } int x = a[0]; int y = a[1]; for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { a[0] <<= i; a[1] <<= j; int[] c = check(a); if (c != null) { Arrays.stream(c).forEach(System.out::println); return; } a[0] = x; a[1] = y; } } } }
第二题. 76%
最后2分钟想到坑点了
BBBBBW WWWW.. BBBBBW WWWW..
这种情况是不合法的
但是
BBBBB ....B ....B ....B ....B
是合法的。
可惜已经没空写了。
第三题。物理渣。理化生就物理最差。混了个64%。刚刚看有个大佬AC了,也发帖了,可以参考他的。
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); while (n-- > 0) { /* x = rcosθ+x0-r y = rsinθ+y0 */ double l0, v0, l1, v1, x0, y0, r, x1, y1; l0 = in.nextInt(); v0 = in.nextInt(); l1 = in.nextInt(); v1 = in.nextInt(); x0 = in.nextInt(); y0 = in.nextInt(); r = in.nextInt(); x1 = in.nextInt(); y1 = in.nextInt(); double θ = Math.acos((x1 + r - x0) / r); double inR = θ * r; double outR = inR + l0; double tAin = inR / v0; double tAout = outR / v0; // tAin .. tAout double y2 = r*Math.sin(θ)+y0; double y3 = y2-l1; double tBin = (y1 - y2) / v1; double tBout = (y1 - y3) / v1; if (tAout <= tBin || tBout <= tAin) { System.out.println("No"); } else { System.out.println("Yes"); } } } }#笔试题目##题解##小马智行#