0
点赞
收藏
分享

微信扫一扫

Java POJ 砝码称重

修炼之士 2022-03-26 阅读 144
java

public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int arr[]=new int[1001];
        String str=sc.nextLine();
        String split[]=str.split(" ");
        int a=Integer.parseInt(split[0]);
        int b=Integer.parseInt(split[1]);
        int c=Integer.parseInt(split[2]);
        int d=Integer.parseInt(split[3]);
        int e=Integer.parseInt(split[4]);
        int f=Integer.parseInt(split[5]);
        int count=0;
        int sum=0;        
        for(int i=0;i<1001;i++) {
            arr[i]=1;
        }        
        for(int i=0;i<=a;i++) {
            for(int j=0;j<=b;j++) {
                for(int k=0;k<=c;k++) {
                    for(int m=0;m<=d;m++) {
                        for(int n=0;n<=e;n++) {
                            for(int o=0;o<=f;o++) {
                            sum=i+2*j+3*k+5*m+10*n+20*o;                            
                            arr[sum]=0;                                        
                            }
                        }
                    }
                }
            }
        }
        for(int i=0;i<1001;i++) {
            if(arr[i]==0) {
                count++;
            }
        }
        System.out.println("Total="+(count-1));
    }
}

举报

相关推荐

B - 砝码称重

砝码称重dp

砝码称重 蓝桥杯

砝码称重C/C++

【python】砝码称重 蓝桥杯

0 条评论