miao的测试 level
获赞
110
粉丝
15
关注
5
看过 TA
17
西安科技大学
2021
Java
IP属地:北京
暂未填写个人简介
私信
关注
2022-04-25 12:16
已编辑
西安科技大学 Java
5道编程题,2个小时,提前AK了,先占坑,等10点以后发题解,看看 java题解转战:https://www.nowcoder.com/discuss/940915 1.竖读 模拟题,一到二星左右 只需竖着把字符放进去,转数字去掉前导零排序即可。 #include<bits/stdc++.h> using namespace std; string s[111111],t[11]; int a[101010]; int main(){    &nbs...
牛客ID280561446:第五题来不及做,用深搜能过70%,提示超时了😂 import java.util.Scanner; public class Main { static int max = Integer.MIN_VALUE; public static void dfs(int[] price, int day, int money, int count){ if(money < 0) return; if(count < 0) return; if(day == price.length-1){ max = Math.max(max, money+count*price[price.length-1]); return; } //买股票 dfs(price, day+1, money-price[day], count+1); //卖股票 dfs(price, day+1, money+price[day], count-1); dfs(price, day+1, money, count); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] price = new int[n]; for (int i = 0; i < n; i++) { price[i] = sc.nextInt(); } dfs(price, 0, m, 0); System.out.println(max); } }
投递腾讯等公司10个岗位 >
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务