九宫格密码有多少种组合
九宫格密码有多少种组合黄冈中考查分
通常设置密码至少4个点,最多9个点,规则通常是两点之间有一点,必须要过中间这个点,比如从1开始,必须要经过2才可以到3。1是可以直接到6的,但通常这种设置比较少。
123
456
789
运行附录的程序得到如下的数据:
size: 4 count0: 144 count1: 96 count2:40
size: 5 count0: 600 count1: 336 count2:152
size: 6 count0: 2880 count1: 1344 count2:304
size: 7 count0: 15120 count1: 4272 count2:496
size: 8 count0: 80640 count1: 18432 count2:1024
size: 9 count0: 362880 count1: 32256 count2:784
sum:  count0: 462264 count1: 56736 count2:2800
use time: 453ms
例如:4个点组合可能有144种可能,排除飞点(1直接到3)的情况,剩下96种可能,如果不考虑跨点(1到6)的情况,仅剩下40种可能。
所以得出的结论是:4-9个点任意组合的九宫格有56736种组合,排除跨点的情况,有2800种可能。
一般人设置在5-7个点,通常形状并不复杂的可能性仅为1000种左右,试出来的可能性还是很大的,而使用4位数字密码的组合则为10000种左右。
源码附录:
package string;
import java.security.InvalidParameterException;
public class HowMany {
public static void main(String[] args) {
String[] except1 = new String[]{
"46", "64", "28", "82", "19", "91", "37", "73",
"13", "31", "39", "93", "97", "79", "17", "71"};
String[] except2 = new String[]{
"16", "61", "18", "81", "34", "43", "38", "83",
"72", "27", "76", "67", "92", "29", "94", "49"};
long lastTime = System.currentTimeMillis();无锡景点介绍
long sum0 = 0;
long sum1 = 0;
long sum2 = 0;
for (int i = 4; i <= 9; i++) {
long count0 = 0;
long count1 = 0;
long count2 = 0;
for (int j = 1; j <= 10 - i; j++) {
Combines num = new Combines(j, i);
String str;
boolean flag1 = false;
boolean flag2 = false;
do {
flag1 = false;
flag2 = false;
str = One();
for (String except : except1) {
含有比喻的成语if (ains(except)) {
充满工作正能量的句子
flag1 = true;
break;
}
}
for (String except : except2) {
if (ains(except)) {
flag2 = true;
break;
}
}
count0++;
if (!flag1) {
count1++;
}
if (!flag1 && !flag2) {
count2++;
//System.out.println(str);
}
} while (veNext());
}
sum0 += count0;
sum1 += count1;
sum2 += count2;
System.out.println("size: " + i + " count0: " + count0 + " count1: " + count1 + " count2:" + count2);
}
System.out.println("sum: " + " count0: " + sum0 + " count1: " + sum1 + " count2:" + sum2);
System.out.println("use time: " + (System.currentTimeMillis() - lastTime) + "ms");
}
private static class Combines {
private int base;
private int[] number;
private int[] poll;
private long amount;
private long count;
public Combines(int start, int size) {
if (size <= 1) {
throw new InvalidParameterException();
}
base = start;
number = new int[size];
poll = new int[size];
amount = this.jieCheng(size);
}
public void reset() {
initNumber();选购红酒
initPoll();
count = 0;
}
public String getOne() {
StringBuffer strBuf = new StringBuffer();
for (int i = 0; i < poll.length; i++) {
strBuf.append(getNumber(poll[i]));
}
String();
}
public boolean moveNext() {
if (++count < amount) {
this.stepNext(1);
this.initNumber();
return true;
} else {
return false;
}
}
private long jieCheng(int x) {
long y = 1;
for (int i = 1; i <= x; i++) {
y = y * i;
}
return y;
梦见电梯}
private int getNumber(int index) {
int num;
for (int i = 0; i < number.length; i++) {
if (number[i] != 0) {
if (index == 0) {
num = number[i];
number[i] = 0;
return num;
}
index--;
}
}
return 0;
}
private void stepNext(int index) {
if (poll[poll.length - 1 - index] == index) {
this.stepNext(index + 1);
poll[poll.length - 1 - index] = 0;
} else {
poll[poll.length - 1 - index]++;
return;
}
}
private void initNumber() {
for (int i = 0; i < number.length; i++) {
number[i] = i + base;
}
}
private void initPoll() {
for (int i = 0; i < poll.length; i++) {
poll[i] = 0;
}
}
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。