当前位置:首页>文档>阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库

阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库

  • 2026-03-05 22:36:02 2026-01-26 20:50:10

文档预览

阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库
阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库
阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库
阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库
阿里2021秋招笔试(8.28)——研发开发岗_2025春招题库汇总_互联网题库-1_02互联网汇总_20、华为_8、华为研发岗位题库

文档信息

文档格式
docx
文档大小
0.033 MB
文档页数
5 页
上传时间
2026-01-26 20:50:10

文档内容

阿里 2021 秋招笔试(8.28)——开发岗 阿里笔试比字节还难,如果你能 A 0-1道,那么你是个努力的臭弟弟, 如果你能 A 一道,人上人,能 A 两道,你一定是Acmer。 祝所有秋招的同学offer拿到手软 一、字符串翻转 对于一个01字符串,每次只能 1. 交换任意两个元素 2. 把一个0变成1或者把一个1变成0 3. 翻转整个串 代码:A 了 0.7 import java.util.Scanner; /** * Created by IntelliJ IDEA. * * @Author: 张志浩 Zhang Zhihao * @Email: 3382885270@qq.com * @Date: 2020/8/28 * @Time: 19:13 * @Version: 1.0 * @Description: Description */ public class First { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); String t = sc.next(); sc.close(); int a1 = 0, a2 = 0, t1 = 0, t2 = 0; for (int i = 0; i < n; i++) { char p1 = s.charAt(i), p2 = t.charAt(i); if (p1 != p2) {if (p1 != '0') t1++; else t2++; } } int tmp = 0; if (t1 < t2) { tmp = t1; t1 = t2; t2 = tmp; } a1 = t1; t1 = 0; t2 = 0; for (int i = 0; i < n; i++) { char p1 = s.charAt(i), p2 = t.charAt(n - i - 1); if (p1 != p2) { if (p1 == '0') t1++; else t2++; } } if (t1 < t2) { tmp = t1; t1 = t2; t2 = tmp; } a2 = t1 + t2; System.out.println(Math.min(a1, a2)); } }  1  2  3  4  5  6  7  8  9 10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50 51  52  53  54  55 二、数字排列 给定两个数 n 和 m ,对 n 中的数重新排列,计算出经过重新排列 后所得到的数中满足不含有前导零并且能够整除 m 的数字有多少个? 例如,n = 520,那么重新排列后:520,502,250,205,025, 052,能被 m = 2整除的,并且无前导零的为 520,502,250三个 代码:全 A import java.util.Scanner; /** * Created by IntelliJ IDEA. * * @Author: 张志浩 Zhang Zhihao * @Email: 3382885270@qq.com * @Date: 2020/8/28 * @Time: 19:42 * @Version: 1.0 * @Description: Description */ public class Second { private static long[][] dp; private static char[] s; private static int m; public static void main(String[] args) { Scanner sc = new Scanner(System.in); s = ("" + sc.nextLong()).toCharArray(); m = sc.nextInt(); sc.close(); dp = new long[(int) Math.pow(2, s.length)][m]; for (long[] a : dp)for (int i = 0; i < a.length; i++) a[i] = -1; System.out.println(getDP(0, 0)); } private static long getDP(int mask, int mod) { if (dp[mask][mod] >= 0) return dp[mask][mod]; if (mask == dp.length - 1) { dp[mask][mod] = mod == 0 ? 1 : 0; return dp[mask][mod]; } dp[mask][mod] = 0; boolean[] used = new boolean[10]; for (int i = 0; i < s.length; i++) if (!used[s[i] - '0'] && (mask | 1 << i) != mask && (mask > 0 || s[i] != '0')) { dp[mask][mod] += getDP(mask | 1 << i, (10 * mod + (s[i] - '0')) % m); used[s[i] - '0'] = true; } return dp[mask][mod]; } }