关注
package sdkd_2019_4th;
import java.util.Scanner;
public class t6 {
static int max=-1;
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
String str[]=new String[n];
int rs[]=new int[n];
for(int i=0;i<n;i++) {
str[i]=s.next();
rs[i]=s.nextInt();
}
for(int i=0;i<n;i++) {
max=0;
f(str[i].substring(1),rs[i],Integer.parseInt(str[i].substring(0,1)));
System.out.println(max);
}
}
public static void f(String str,int num,int count) {
if(count==num&&str.equals("")) {
System.out.println(str);
max++;
return;
}
for(int i=0;i<str.length();i++) {
int a=Integer.parseInt(str.substring(i, i+1));
for(int j=0;j<2;j++) {
if(j==0) {
count=count+a;
f(str.substring(i+1),num,count);
count=count-a;
}else {
count=count-a;
f(str.substring(i+1),num,count);
count=count+a;
}
}
}
return;
}
}
哪里不行啊,求解
查看原帖
点赞 2
相关推荐
03-13 18:55
北京师范大学 银行其它 点赞 评论 收藏
分享
04-03 22:41
兰州大学 C++ 点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 你知道最慷慨和最抠的公司分别是 #
3718次浏览 38人参与
# 哪些AI项目值得做? #
2419次浏览 84人参与
# 华泰星战营,提前锁定校招offer #
8834次浏览 316人参与
# 实习时最怕听到的一句话 #
2712次浏览 47人参与
# 简历上如何体现你的“AI”能力? #
2761次浏览 53人参与
# 没有面试的日子里,你在做什么 #
3550次浏览 55人参与
# 怎么给家人解释你的工作? #
57090次浏览 217人参与
# 你简历上最心虚的一句话 #
8213次浏览 49人参与
# 你总挂在第__面? #
1509次浏览 22人参与
# 找不到大厂实习可以去小厂吗? #
2790次浏览 30人参与
# 荣耀笔试 #
83730次浏览 410人参与
# 实习生如何通过转正 #
138148次浏览 1493人参与
# 国央企笔面经互助 #
196942次浏览 1235人参与
# 考公VS就业,你怎么选? #
100741次浏览 534人参与
# 卷__卷不过你们,只能卷__了 #
60927次浏览 767人参与
# 你今年的保底offer是哪家 #
187930次浏览 760人参与
# 大城市找工作会更容易吗 #
66899次浏览 400人参与
# 哪些公司对双非友好 #
231177次浏览 1248人参与
# 快消秋招求职进展汇总 #
11717次浏览 43人参与
# 你找实习最大的坎坷是什么 #
322275次浏览 2467人参与
# 哪些公司校招卡第一学历 #
256708次浏览 876人参与
查看4道真题和解析