HDACM2200
关键字眼:从中选择一部分人(或者全部)按照ac的数量分成两组进行比较
此题采用递推的做法:
1个人: —> 0*2+0
2个人: 2:1 —> 0*2+1
3个人: (2:1 32:1) 3:1/2 3:12 —> 1*2+3
4个人:(42:1 432:1 43:1/2 43:12) 4:1/2/3 4:12/13/23 4:123 —> 5*2+7
可知 n = (n-1)*2+2^(n-1)-1;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()) {long n = sc.nextInt();long count = 0;for (long i = 1; i <= n ; i++) {count = count*2-1+(long)Math.pow(2, i-1);}System.out.println(count);}}
}