全部评论
楼主,请问可以分享一下三道题目吗?我没赶上昨晚的笔试
楼主,请问华为机试可以使用本地编译器吗
第三题样例2 有多种不同的路径,题目也没说咋处理,就是0-3-8,0-7-8都能到8,推荐值也不同,最终取哪个?。还是我看错题了?
1,1,0.3。。
今晚华为笔试的牛友们,你们过了几道题呢
1 0.3 0
第三题:差一个排序输出,,, import java.util.Scanner;
public class Test006 {
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
int group = scanner.nextInt();
while (group >= 1)
{
int userNum = scanner.nextInt();
int target = scanner.nextInt();
int degree = scanner.nextInt();
int[][] users = new int[userNum][userNum];
int[][] degrees = new int[userNum][userNum];
for (int j = 0; j < userNum; j++)
{
for (int k = 0; k < userNum; k++)
{
if (j == k)
{
users[j][k] = -1;
degrees[j][k] = -1;
}
else
{
users[j][k] = 0;
degrees[j][k] = 0;
}
}
}
int num = scanner.nextInt();
for (int i = 0; i < num; i++)
{
int user1 = scanner.nextInt();
int user2 = scanner.nextInt();
users[user1][user2] = users[user2][user1] = scanner.nextInt();
degrees[user1][user2] = degrees[user2][user1] = 1;
}
deal(users, degrees,target);
for (int l = 0; l < userNum; l++)
{
if (degrees[target][l] == degree)
{
System.out.print((users[target][l]) + " ");
}
}
group--;
}
}
public static void deal(int[][] array, int[][] degree, int row)
{
int rows = array.length;
for(int col = 0; col < rows;col++)
{
if(array[row][col] != -1 && array[row][col] != 0)
{
for(int j = 0 ; j < rows; j++)
{
if(array[col][j] != -1 && array[col][j] != 0 && array[row][j] == 0)
{
array[j][row] = array[row][j] = array[col][j] + array[row][col];
degree[j][row] = degree[row][j] = degree[col][j] + degree[row][col];
}
}
}
}
}
第一个题死活卡在0.66,不知道哪个case过不去
问一下华为笔试用的牛客系统还是赛码系统?
多少分算通过有人知道吗?
相关推荐
offerSuL:不认字,打电话说
点赞 评论 收藏
分享