Huawei OD マシンのテストリリース Apple (C++ & Java & JS & Python)

説明する

m個の同じリンゴを n個の同じ皿に置き、いくつかの皿を空のままにします。それらを分ける方法は何通りありますか?

注: 7 つのリンゴと 3 つの皿がある場合、(5, 1, 1) と (1, 5, 1) は同じ除算とみなされます。

データ範囲: 0≤�≤10 0≤m≤10、1≤�≤10 1≤n≤10。

説明を入力してください:

2 つの int 整数を入力してください

出力の説明:

出力結果、int型

例1

入力:

7 3

出力:

8

ジャバ:

import java.util.Scanner;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNextInt())
        {
            System.out.println(count(sc.nextInt(),sc.nextInt()));
        }
        sc.close();
    }
    public static int count(int m,int n)
    {
        if(m<0||n<=0)
           return 0;
        //细分到苹果数为一或盘子数为一的情况返回一
        if(m==1||n==

おすすめ

転載: blog.csdn.net/m0_68036862/article/details/132850292