1.另类加法
/**
* 另类加法
*/
public int addAB (int A,int B){
if (B==0){
return A;
}
int sum = 0;
int carry = 0;
while(B!= 0){
sum = A^B;
carry = (A&B)<<1;
A = sum;
B = carry;
}
return A;
}
2.最路径总数
/**
* 走方格的方案数
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//输入多组样例,所以要循环读出
while(sc.hasNext()){
int n = sc.nextInt();
int m = sc.nextInt();
System.out.println(med(m,n));
}
}
private static int med(int n, int m) {
if((n ==1 && m >= 1 )|| (m==1 && n >=1)){
return m + n;
}
//递归
return med(n-1,m)+ med(n,m-1);
}