Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- /**
- *
- * @author User
- */
- public class JavaApplication1 {
- /**
- * @param args the command line arguments
- * @throws java.io.IOException
- */
- public static void main(String[] args) throws IOException {
- int a;
- int b;
- int c;
- int m;
- int n;
- int kombinacije = 0;
- int pocetak;
- InputStreamReader inputStreamReader = new InputStreamReader(System.in);
- BufferedReader reader = new BufferedReader(inputStreamReader);
- a = Integer.parseInt(reader.readLine());
- b = Integer.parseInt(reader.readLine());
- c = Integer.parseInt(reader.readLine());
- m = Integer.parseInt(reader.readLine());
- n = Integer.parseInt(reader.readLine());
- pocetak = n / c;
- for (int i = pocetak; i >= 0; i--) {
- for (int j = 0; j <= m - i; j++) {
- if ((i * c + j * b) == n & (i + j) == m) {
- kombinacije++;
- System.out.println(i + " " + j + " " + 0);
- }
- if ((i * c + j * b) > n) {
- break;
- }
- for (int k = 1; k <= m - i - j; k++) {
- if ((i * c + j * b + k * a) == n & (i + j + k) == m) {
- kombinacije++;
- System.out.println(i + " " + " " + j + " " + k);
- }
- if ((i * c + j * b + k * a) > n) {
- break;
- }
- }
- }
- }
- System.out.println(kombinacije);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement