@GatorGirl/

FloralwhiteOlivedrabSubversion

C++11

No description

fork
loading
Files
  • main.cpp
  • main
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int calcWays(int amount, vector<int> coins, int &ways)
{
  cout << endl;
  //int count = 0;
  if (amount <= 0)
  {
    return 1;
  }
  int largestCoin = 0;
  int i;
  cout << "starting amount: " << amount << endl;
  for (i = 0; i < coins.size(); i ++)
  {
    if (amount >= coins[i])
    {
      largestCoin = coins[i];
    }
    else 
    {
      break;
    }
  }
  cout << "largest coin: " << largestCoin << endl;
  int index = i;
  int remainder = amount;
  cout << "remainder: " << remainder << endl;
  //int currCoin = largestCoin;
  while(remainder > 0)
  {
    int div = amount/largestCoin;
    for(int j = 0; j <= div; j ++)
    {
      cout << "j: " << j << endl;
      remainder = remainder - largestCoin * j;
      calcWays(remainder, coins, ways);
    }
    //i --;
    //currCoin = coins[i];
  }
  return 0;//fix this
}

int main() 
{
  int amount;
  cin >> amount;

  vector<int> coins;
  int num = 1;
  while (num <= 21)
  {
    coins.push_back(num * num * num);
    num ++;
  }

  //int ways = 0;
  //calcWays(amount, coins, ways);
  //cout << ways << endl;

  int largestCoin = 0;
  int i;
  for (i = 0; i < coins.size(); i ++)
  {
    if (amount >= coins[i])
    {
      largestCoin = coins[i];
    }
    else 
    {
      break;
    }
  }
  int div = amount/largestCoin;
  while (i > 0)
  {
    for (int j = 0; j < i; j ++)
    {
      if (amount >= coins[j])
      {
        largestCoin = coins[j];
      }
      else 
      {
        break;
      }
    }
    cout << largestCoin << endl;
    div += amount/largestCoin;
    cout << div << endl << endl;
    i --;
  }
  //cout << div + 1 << endl;
  return 0;
}