核桃的数量
小张是软件项目经理,他带领3个开发组。工期紧,今天都在加班呢。为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑)。他的要求是:
各组的核桃数量必须相同
各组内必须能平分核桃(当然是不能打碎的)
尽量提供满足1,2条件的最小数量(节约闹革命嘛)
import java.util.Scanner;
public class Main {
public static int gys(int a,int b) {
while(true) {
if(a%b==0) {
return b;
}else {
return gys(b,a%b);
}
}
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int temp = gys(a,b);
temp = a*b/temp;
int t = gys(temp,c);
temp = temp*c/t;
System.out.println(temp);
}
}
打印十字图
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static int t;
public static boolean yuan(int a,int b,int c,int d) {
if(Math.abs(a-2*t-2)+Math.abs(b-2*t-2)>Math.abs(c-2*t-2)+Math.abs(d-2*t-2)) {
return true;
}
return false;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
t = sc.nextInt();
int [][] m = new int[4*t+5][4*t+5];
for(int i=0;i<m.length;i++) {
for(int j=0;j<m[0].length;j++) {
m[i][j] = -1;
}
}
int[] sx = {2*t+2,2*t,2*t+1,2*t+3,2*t+4,2*t+2,2*t+2,2*t+2,2*t+2};
int[] sy = {2*t+2,2*t+2,2*t+2,2*t+2,2*t+2,2*t,2*t+1,2*t+3,2*t+4};
int[] dx = {1,1,1,0,-1,-1,-1,0};
int[] dy = {1,0,-1,-1,-1,0,1,1};
ArrayList ax = new ArrayList();
ArrayList ay = new ArrayList();
for(int i=0;i<sx.length;i++) {
ax.add(sx[i]);
ay.add(sy[i]);
m[sx[i]][sy[i]] = 1;
}
for(int n=0;n<t;n++) {
//。
ArrayList tax = new ArrayList();
ArrayList tay = new ArrayList();
for(int in=0;in<ax.size();in++) {
for(int i=0;i<dx.length;i++) {
int tx = (int)ax.get(in)+dx[i];
int ty = (int)ay.get(in)+dy[i];
if(m[tx][ty]==-1) {
m[tx][ty] = 0;
tax.add(tx);
tay.add(ty);
}
}
}
ax = tax;
ay = tay;
ArrayList ttax = new ArrayList();
ArrayList ttay = new ArrayList();
for(int in=0;in<ax.size();in++) {
for(int i=0;i<dx.length;i++) {
int tx = (int)ax.get(in)+dx[i];
int ty = (int)ay.get(in)+dy[i];
if(m[tx][ty]==-1) {
m[tx][ty] = 1;
ttax.add(tx);
ttay.add(ty);
}
}
}
ax = ttax;
ay = ttay;
}
for(int i=0;i<m.length;i++) {
for(int j=0;j<m[0].length;j++) {
if(m[i][j]==1) {
System.out.print('$');
}else {
System.out.print('.');
}
}
System.out.println();
}
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
//static int[] m = new int[10];
static ArrayList a = new ArrayList();
static int[] dic = new int[10];
; public static void dabiao(int n,int cur) {
if(n==10) {
a.add(cur);
}else if(n==1){
for(int i=1;i<10;i++) {
dic[i] = 1;
dabiao(2,i);
dic[i] = 0;
}
}else {
for(int i=1;i<10;i++) {
if(dic[i]==0) {
dic[i] = 1;
dabiao(n+1,cur*10+i);
dic[i] = 0;
}
}
}
}
public static int qu(int target,int x,int y,int z) {
int res = 0;
for(int i=0;i<a.size();i++) {
int temp = (int)a.get(i);
int num1 = temp%(int)Math.pow(10,z);
temp = temp/(int)Math.pow(10,z);
int num2 = temp%(int)Math.pow(10,y);
temp = temp/(int)Math.pow(10,y);
int num3 = temp%(int)Math.pow(10,x);
if(num2%num1!=0) {
continue;
}
double num = num3 + num2/num1;
if(target==num) {
//System.out.println(num3);
//System.out.println(num2);
//System.out.println(num1);
res++;
}
}
return res;
}
public static void main(String args[]) {
for(int i=0;i<dic.length;i++) {
dic[i] = 0;
}
dabiao(1,0);
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int res = 0;
if(n/10==0) {
res = qu(n,1,4,4);
}else if(n/100==0) {
res = qu(n,1,5,3) + qu(n,2,4,3)+qu(n,1,4,4)+qu(n,1,6,2);
}else if(n/1000==0) {
res = qu(n,3,3,3) + qu(n,2,5,2) + qu(n,1,5,3) + qu(n,3,4,2)+qu(n,2,4,3);
}else if(n/10000==0) {
res = qu(n,1,6,2) + qu(n,4,4,1) + qu(n,4,3,2)+qu(n,3,3,3)+qu(n,2,5,2);
}else if(n/100000==0) {
res = qu(n,2,6,1) + qu(n,5,2,2) + qu(n,5,3,1)+qu(n,1,6,2)+qu(n,4,4,1)+qu(n,4,3,2);
}else if(n/1000000==0) {
res = qu(n,1,7,1) + qu(n,6,2,1)+qu(n,2,6,1)+qu(n,5,2,2)+qu(n,5,3,1);
}else if(n/10000000==0) {
res = qu(n,7,1,1)+qu(n,1,7,1)+qu(n,6,2,1);
}else if(n/100000000==0) {
res = qu(n,7,1,1)+qu(n,1,7,1)+qu(n,6,2,1);
}
System.out.println(res);
}
/**
public static void main(String args[]) {
System.out.println(39176/425);
}
**/
}
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static int[][] row = new int[6][6];
static int[][] col = new int[6][6];
static int[][] area = new int[6][6];
static int[][] map = new int[6][6];//得到分区号
static char[][] value = new char[6][6];
static ArrayList<String> list = new ArrayList<String>();
static void init() {
for(int i=0;i<6;i++) {
for(int j=0;j<6;j++) {
row[i][j] = -1;
col[i][j] = -1;
map[i][j] = -1;
area[i][j] = -1;
value[i][j] = '0';
}
}
}
static void readip(String[] a,String[] b) {
for(int i=0;i<a.length;i++) {
for(int j=0;j<a[0].length();j++) {
map[i][j] = a[i].charAt(j)-'0';
}
}
for(int i=0;i<b.length;i++) {
int x = b[i].charAt(0)-'0';
int y = b[i].charAt(1) -'0';
int z = b[i].charAt(2)-'A';
row[x][z] = 1;
col[y][z] = 1;
area[map[x][y]][z] = 1;
value[x][y] = b[i].charAt(2);
}
}
static boolean check(int step,int v) {
int x = step/6;
int y = step%6;
for(int i=0;i<6;i++) {
if(row[x][v]==1||col[y][v]==1||area[map[x][y]][v]==1) {
return false;
}
}
return true;
}
static void dfs(int step) {
if(step==36) {
StringBuilder sb = new StringBuilder("");
for(int i=0;i<6;i++) {
for(int j=0;j<6;j++) {
sb.append(value[i][j]);
}
}
list.add(sb.toString());
return;
}
int x = step/6;
int y = step%6;
if(value[x][y]!='0') {
dfs(step+1);
return;
}
for(int i=0;i<6;i++) {
if(check(step,i)) {
row[x][i]=1;
col[y][i]=1;
area[map[x][y]][i]=1;
value[x][y]=(char)('A'+i);
/**
for(int m=0;m<6;m++) {
for(int n=0;n<6;n++) {
System.out.print(value[m][n]);
}
System.out.println();
}
**/
dfs(step+1);
row[x][i]=-1;
col[y][i]=-1;
area[map[x][y]][i]=-1;
value[x][y]='0';
}
}
}
static void show() {
for(int i=0;i<list.size();i++) {
String str = list.get(i);
System.out.println(i+1);
for(int j=0;j<6;j++) {
for(int k=0;k<6;k++) {
System.out.print(str.charAt(j*6+k));
if(k!=5) {
System.out.print(" ");
}else {
System.out.println();
}
}
}
}
}
public static void main(String[] args) {
init();
Scanner sc = new Scanner(System.in);
String[] a = new String[6];
for(int i=0;i<6;i++) {
String tmp = sc.nextLine();
a[i] = tmp;
}
int n = sc.nextInt();
sc.nextLine();
String[] b = new String[n];
for(int i=0;i<n;i++) {
String tmp = sc.nextLine();
b[i] = tmp;
}
readip(a,b);
dfs(0);
show();
}
}
疑问:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
long[] m = new long[30100];
int[] v = new int[40];
int[] s = new int[40];
Scanner sc = new Scanner(System.in);
int money = sc.nextInt();
int n = sc.nextInt();
for(int i=0;i<money;i++) {
m[i] = 0;
}
sc.nextLine();
for(int i=0;i<n;i++) {
int a = sc.nextInt();
int b= sc.nextInt();
v[i] = a*b;
s[i] = a;
sc.nextLine();
}
for(int i=0;i<n;i++) {
for(int j=money;j>=s[i];j--) {
m[j] = Math.max(m[j], m[j-s[i]]+v[i]);
}
}
System.out.println(m[money]);
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] v = new int[m + 1];
int[] w = new int[m + 1];
int[][] f = new int[m + 1][n + 1];
for(int i = 1;i <= m;i++){
v[i] = sc.nextInt();
w[i] = sc.nextInt();
}
for(int j = 0;j < n;j++){
f[0][j] = 0;
}
for(int i = 1;i <= m;i++){
for(int j = 0;j <= n;j++){
f[i][j] = f[i-1][j];
if(j >= v[i]){
f[i][j] = Math.max(f[i - 1][j],f[i-1][j - v[i]] + v[i] * w[i]);
}
}
}
System.out.println(f[m][n]);
}
}
这两个写法有什么区别???
- PREV-19 九宫重排
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
static boolean flag = false;
static String fin;
static HashMap<String,Integer> m = new HashMap<String,Integer>();
static Queue<String> s = new LinkedList<String>();
static String f(String str,int a,int b) {
String temp = String.valueOf(str.charAt(a));
StringBuilder sb = new StringBuilder(str);
sb.replace(a, a+1, String.valueOf(str.charAt(b)));
sb.replace(b, b+1, temp);
return sb.toString();
}
static String[] change(String str,int i) {
String[] slist = new String[4];
if(i==0) {
slist[0] = f(str,0,1);
slist[1] = f(str,0,3);
}else if(i==1) {
slist[0] = f(str,0,1);
slist[1] = f(str,1,2);
slist[2] = f(str,1,4);
}else if(i==2) {
slist[0] = f(str,1,2);
slist[1] = f(str,2,5);
}else if(i==3) {
slist[0] = f(str,0,3);
slist[1] = f(str,3,4);
slist[2] = f(str,3,6);
}else if(i==4) {
slist[0] = f(str,1,4);
slist[1] = f(str,4,3);
slist[2] = f(str,4,5);
slist[3] = f(str,4,7);
}else if(i==5) {
slist[0] = f(str,2,5);
slist[1] = f(str,4,5);
slist[2] = f(str,5,8);
}else if(i==6) {
slist[0 ] = f(str,3,6);
slist[1] = f(str,6,7);
}else if(i==7) {
slist[0 ] = f(str,4,7);
slist[1] = f(str,6,7);
slist[2] = f(str,7,8);
}else {
slist[0] = f(str,5,8);
slist[1] = f(str,7,8);
}
return slist;
}
static void bfs(String str,int cur) {
if(str.equals(fin)) {
flag = true;
System.out.print(cur);
return;
}
int i = str.lastIndexOf('.');
int n = 3;
String[] slist = change(str,i);
if(i==0||i==2||i==6||i==8) {
n = 2;
}else if(i==4){
n = 4;
}
for(int in=0;in<n;in++) {
//System.out.println("start check for " + slist[in]);
//System.out.println(m.size());
if(!m.containsKey(slist[in])) {
m.put(slist[in],cur+1);
s.add(slist[in]);
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String ori = sc.nextLine();
fin = sc.nextLine();
bfs(ori,0);
while(!s.isEmpty()) {
String temp = s.poll();
bfs(temp,m.get(temp));
}
if(!flag)System.out.print(-1);
}
}
PREV-22 国王的烦恼
这题得用并查集按size来合并,注意days的更新(本来写错成cur++...找了半天错误在哪儿)
并查集的实现--------------------------------------------------------------??????????????????()
/*
* 首先将桥逐步消失转化为从最后一天开始桥逐步增加
* 若增加的桥使得堆减少了,则说明去掉这些桥会使堆增加---->这天结束之后要抗议
*
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
class San implements Comparable<San>{
public int a;
public int b;
public int c;
public San(int a,int b,int c) {
super();
this.a = a;
this.b = b;
this.c = c;
}
@Override
public int compareTo(San s) {
return this.a-s.a;
}
public String toString() {
return String.valueOf(this.a)+String.valueOf(this.b)+String.valueOf(this.c);
}
}
public class Main {
public static void main(String[] args) {
List<San> li = new ArrayList<San>();
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
sc.nextLine();
int[] a = new int[m];
int[] b = new int[m];
int[] c = new int[m];
int maxd = 0;
for(int i=0;i<m;i++) {
int x = sc.nextInt();
int y = sc.nextInt();
int days = sc.nextInt();
sc.nextLine();
a[i] = x;
b[i] = y;
c[i] = days;
maxd = Math.max(maxd,days);
}
for(int i=0;i<m;i++) {
San temp = new San(maxd-c[i],a[i],b[i]);
li.add(temp);
}
UnionFind uf = new UnionFind(n);
Collections.sort(li);
int res = 0;
int[] mm = new int[n+1];
for(int i=0;i<n+1;i++) {
mm[i] = i;
}
int cur = 0;
boolean flag = false;
for(int i=0;i<m;i++) {
if(li.get(i).a>cur) {
if(flag)res++;
flag = false;
cur = li.get(i).a;
}
int tx = li.get(i).b;
int ty = li.get(i).c;
if(!uf.connected(tx,ty)) {
//合并
uf.union(tx,ty);
flag = true;
}
}
if(flag)res++;
System.out.println(res);
}
}
class UnionFind {
private int[] id;
private int count;
private int[] sz;
public UnionFind(int N) {
count = N;
id = new int[N+1];
sz = new int[N+1];
for(int i = 1; i < N+1; i++) {
id[i] = i;
sz[i] = 1;
}
}
public int getCount() {
return count;
}
public boolean connected(int p, int q) {
return find(p) == find(q);
}
public int find(int p) {
if (p != id[p]) id[p] = find(id[p]);
return id[p];
}
public void union(int p, int q){
int pRoot = find(p);
int qRoot = find(q);
if(pRoot == qRoot) return;
if(sz[pRoot] < sz[qRoot]) { id[pRoot] = qRoot; sz[qRoot] += sz[pRoot]; }
else { id[qRoot] = pRoot; sz[pRoot] += sz[qRoot]; }
count--;
}
}
单位分数
(这题题目描述是不超过30,但是实际上要求的却是小于30....不过一下子就做出来了还是很开心)
import java.util.Scanner;
//暂时不考虑1/1
public class Main {
static int num;
static int[] m;
public static boolean cal() {
int a = 1;
int b = m[num-1];
for(int i=num-2;i>=0;i--) {
int c = m[i];
int mu = c*b;
int zi = a*c+b;
a = zi;
b = mu;
}
return a==b;
}
public static void dfs(int n) {
if(n==num) {
if(cal()) {
for(int i=0;i<num;i++) {
System.out.print("1/");
System.out.print(m[i]);
if(i!=num-1)System.out.print(" ");
}
System.out.println();
}
return;
}
if(n==0) {
for(int i=2;i<30;i++) {
m[0] = i;
dfs(1);
}
}else {
for(int i=m[n-1]+1;i<30;i++) {
m[n] = i;
dfs(n+1);
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
m = new int[num];
dfs(0);
}
}
- 上帝造题五分钟
这题测试数据只有一条,不太靠谱,纯练一下搜素优化的编程实现
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
//元素对产生的数组,按第一个元素值进行排序
//前后两组元素对的元素为abcd,前一对得到的最小值在e
//若e在cd中间,则c到e的元素可以换成e
//总结下来只需要记录之前检索过的最大的下标maxi,和maxi对应的那个最小值对应的下标cmin
class Er implements Comparable<Er>{
int a;
int b;
int c;
public Er(int a,int b,int c) {
this.a = a;
this.b = b;
this.c = c;
}
@Override
public int compareTo(Er e) {
if(this.a!=e.a)return this.a-e.a;
return this.b-e.b;
}
public String toString() {
return String.valueOf(this.a)+String.valueOf(b);
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
ArrayList<Er> li = new ArrayList<Er>();
sc.nextLine();
int[] s = new int[n];
for(int i=0;i<n;i++) {
int temp = sc.nextInt();
s[i] = temp;
}
sc.nextLine();
for(int i=0;i<q;i++) {
int a = sc.nextInt();
int b = sc.nextInt();
Er e = new Er(a,b,i);
li.add(e);
}
Collections.sort(li);
int maxi = -1;
int cmin = -1;
int[] res = new int[q];
int t = 2000;
for(int i=li.get(0).a;i<=li.get(0).b;i++) {
if(t>=s[i]) {
t = s[i];
cmin = i;
}
}
maxi = li.get(0).b;
//System.out.println(t);
res[li.get(0).c] = t;
for(int i=1;i<q;i++) {
t = 2000;
if(cmin>=li.get(i).a&&cmin<=li.get(i).b) {
t = s[cmin];
for(int j=maxi+1;j<=li.get(i).b;j++) {
if(t>=s[j]) {
t = s[j];
cmin = j;
}
}
}else {
for(int j=li.get(i).a;j<=li.get(i).b;j++) {
if(t>=s[j]) {
t = s[j];
cmin = j;
}
}
}
maxi = li.get(i).b;
//System.out.println(t);
res[li.get(i).c] = t;
}
for(int i=0;i<q;i++) {
System.out.println(res[i]);
}
}
}
- 5.7对数字
其实就是dfs
public class Main {
static int[] a = new int[12];
static boolean flag = false;
static void f(int num) {
for(int i=0;i<12;i++) {
System.out.print(a[i]);
}
System.out.println();
if(num==4) {
f(3);
return;
}
if(num==0) {
flag = true;
System.out.print("74");
for(int i=0;i<12;i++) {
System.out.print(a[i]);
}
}
for(int i=0;i+num+1<=11;i++) {
if(a[i]!=0 || a[i+num+1]!=0)continue;
a[i] = num;
a[i+num+1] = num;
f(num-1);
if(flag)break;
a[i] = 0;
a[i+num+1] = 0;
}
}
public static void main(String[] args) {
System.out.print("74151643752362");
}
}
BASIC-23 芯片测试
其实还是dfs,遍历芯片认为芯片是真,然后不断按结果往下走,若有错误则返回false,选下一个芯片
注意芯片的flag在每次弄完之后要复原,但因为没有分支所以不需要用回溯的办法时时复原
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Scanner;
class Scit implements Comparable<Scit>{
public int[] tlist;//-1表示无意义
public int num = 0;//list中1的数目
public int flag = -1;//-1未知,0坏,1好
@Override
public int compareTo(Scit arg0) {
return this.num - arg0.num;
}
}
public class Main {
static ArrayList<Scit> a = new ArrayList<Scit>();
static int num;
static boolean dfs(int[] ce) {
for(int i=0;i<num;i++) {
if(ce[i]==0) {//检查每个位置有没有问题
if(a.get(i).flag==0) continue;
else if(a.get(i).flag==1)return false;
else {
a.get(i).flag = 0;
}
}else if(ce[i]==1) {
if(a.get(i).flag==1)continue;
else if(a.get(i).flag==0)return false;
else {
a.get(i).flag = 1;
if(dfs(a.get(i).tlist))continue;
else return false;
}
}
}
return true;
}
//先不考虑计数之后好的少于一般直接判负的剪枝
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
for(int i=0;i<num;i++) {
Scit t = new Scit();
t.tlist = new int[num];
for(int j=0;j<num;j++) {
int r = sc.nextInt();
t.tlist[j] = r;
t.num += r;
if(i==j)t.tlist[j] = -1;
}
t.num--;
a.add(t);
}
for(int i=0;i<num;i++) {
a.get(i).flag = 1;
if(dfs(a.get(i).tlist)) {
for(int j=0;j<num;j++) {
int res = a.get(i).tlist[j];
if(res==1||res==-1) {
System.out.print(j+1);
System.out.print(" ");
}
}
break;
}
else {
for(int j=0;j<num;j++)a.get(j).flag = -1;//恢复
}
}
}
}
- 找素数
就是用筛法打表了而已
public class Main {
static long[] su = new long[100010];
//先不考虑计数之后好的少于一般直接判负的剪枝
public static void main(String[] args) {
su[0] = 2;
su[1] = 3;
for(int i=2;i<su.length;i++) {
long j=su[i-1]+2;
while(true) {
boolean flag = true;
for(int t=1;t<i;t++) {
if(j%su[t]==0) {
flag = false;
break;
}
}
if(flag)break;
j+=2;
}
System.out.println(j);
su[i] = j;
}
System.out.println(su[100001]);
}
}
七段码
import java.awt.datatransfer.SystemFlavorMap;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
static int[] cur = new int[7];
static int[][] temp= {{0,1},{0,5},{1,6},{5,6},{6,2},{2,3},{4,3},{4,6},{4,5},{1,2}};
static ArrayList<ArrayList<Integer>> a;
public static void gen(int num) {
int i=0;
for(i=0;i<7;i++) {
int t = num%2;
cur[i] = t;
num/=2;
}
/**
for(i=0;i<7;i++) {
System.out.print(cur[i]);
}
System.out.println();
**/
}
public static boolean check() {
int[] t = new int[7];
for(int i=0;i<7;i++)t[i] = 0;
Queue<Integer> q = new LinkedList<Integer>();
for(int i=0;i<7;i++) {
if(cur[i]==1) {
q.add(i);
break;
}
}
while(!q.isEmpty()) {
int num = q.poll();
if(t[num]==1)continue;
t[num] = 1;
for(int i=0;i<a.get(num).size();i++) {
int getnum = a.get(num).get(i);
if(cur[getnum]==1) {
q.add(getnum);
}
}
}
for(int i=0;i<7;i++) {
if(t[i]!=cur[i])return false;
}
return true;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
a = new ArrayList< ArrayList<Integer> >();
for(int i=0;i<7;i++) {
a.add(new ArrayList<Integer>());
}
for(int i=0;i<temp.length;i++) {
int n1 = temp[i][0];
int n2 = temp[i][1];
a.get(n1).add(n2);
a.get(n2).add(n1);
}
int res = 0;
for(int i=0;i<128;i++) {
gen(i);
if(check()) {
for(int j=0;j<7;j++) {
System.out.print(cur[j]);
}
res++;
System.out.println();
}
}
res-=1;//去除全0
System.out.print(res);
}
}