8.6---大疆软件B卷笔试。
选择题(不定项题目)。不一定多选,很多其实的单选。随缘得分
100% 100% 0
编程题:
第一题:01背包问题--动态规划
import java.util.Scanner; public class dji { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int j = 0; j < T; j++) { int N = sc.nextInt(); int X = sc.nextInt(); int[] Ai = new int[N]; int[] Bi = new int[N]; for (int i = 0; i < N; i++) { Ai[i] = sc.nextInt(); Bi[i] = sc.nextInt(); } dfs(N, X, Bi, Ai); } sc.close(); } public static void dfs(int N, int X, int[] Ai, int[] Bi) { int []count = new int[X + 1]; for (int m : count) { m = 0; } for (int i = 0; i < N; i++) { int w = Ai[i]; int v = Bi[i]; for (int j = X; j >= w; j--) { count[j] = Math.max(count[j], count[j - w] + v); } } System.out.println(count[X]); } }
AC 100%
第二题:hashmap.先浏览了一遍编程题,首先做了第二题,10min
import java.util.HashMap; import java.util.Scanner; public class dji1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); int m = sc.nextInt(); HashMapmap=new HashMap(); for(int i=0;i<n;i++){ String string1=sc.next(); String string2=sc.next(); map.put(string1, string2); } for(int j=0;j<m;j++){ String string3=sc.next(); if(map.get(string3)!=null) System.out.println(map.get(string3)); } } sc.close(); } }
AC 100%
第三题:花了很多分钟,依旧无果.坐等大佬思路
祝愿给个面试机会,毕竟编程不易。