Advertisement
Guest User

Untitled

a guest
May 20th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication1;
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.IOException;
  10. import java.io.InputStreamReader;
  11.  
  12. /**
  13. *
  14. * @author User
  15. */
  16. public class JavaApplication1 {
  17.  
  18. /**
  19. * @param args the command line arguments
  20. * @throws java.io.IOException
  21. */
  22. public static void main(String[] args) throws IOException {
  23. int a;
  24. int b;
  25. int c;
  26. int m;
  27. int n;
  28. int kombinacije = 0;
  29. int pocetak;
  30.  
  31. InputStreamReader inputStreamReader = new InputStreamReader(System.in);
  32. BufferedReader reader = new BufferedReader(inputStreamReader);
  33. a = Integer.parseInt(reader.readLine());
  34. b = Integer.parseInt(reader.readLine());
  35. c = Integer.parseInt(reader.readLine());
  36. m = Integer.parseInt(reader.readLine());
  37. n = Integer.parseInt(reader.readLine());
  38.  
  39. pocetak = n / c;
  40. for (int i = pocetak; i >= 0; i--) {
  41. for (int j = 0; j <= m - i; j++) {
  42. if ((i * c + j * b) == n & (i + j) == m) {
  43. kombinacije++;
  44. System.out.println(i + " " + j + " " + 0);
  45. }
  46. if ((i * c + j * b) > n) {
  47. break;
  48. }
  49. for (int k = 1; k <= m - i - j; k++) {
  50. if ((i * c + j * b + k * a) == n & (i + j + k) == m) {
  51. kombinacije++;
  52. System.out.println(i + " " + " " + j + " " + k);
  53. }
  54. if ((i * c + j * b + k * a) > n) {
  55. break;
  56. }
  57. }
  58. }
  59. }
  60. System.out.println(kombinacije);
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement