标签:poi ott ext turn system org log ges 判断
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 33214 | Accepted: 20600 |
Description
Input
Output
Sample Input
1 7 3
Sample Output
8
题解:直接暴力,刚开始还以为不能有盘子空着吶,允许有盘子空着,所以直接暴力就可以了:
代码:
package com.lanqiao.week2; import java.util.Scanner; public class H { private static Scanner cin; static{ cin = new Scanner(System.in); } private static int k; static void cal(int M, int N, int cnt, int cur, int v){ if(cnt < 0){ return; } if(v == M){ // System.out.println("M = " + M + "N = " + N + "cnt = " + cnt + "cur = " + cur + "v = " + v); k++; return; } if(cur > M || v > M){ return; } for(int i = 0; i <= N; i++){ cal(M, N, cnt - i, cur + 1, v + cur * i); } } public static void main(String[] args) { int t = cin.nextInt(); int M, N; while(t-- > 0){ M = cin.nextInt(); N = cin.nextInt(); k = 0; cal(M, N, N, 1, 0); System.out.println(k); } } }
Description
Input
Output
Sample Input
Sample Output
标签:poi ott ext turn system org log ges 判断
原文地址:http://www.cnblogs.com/handsomecui/p/6556994.html