I'm having problem with this code:
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
long long addV(int i) {
return pow(10,i);
}
int len;
void recurse(int n,long long &ways,int values[],int current=0,int p=0) {
if(p>len) return;
if(current>n) return;
if(current ==n) {
ways++;
return;
}
int cv = n-current;
cv/=values[p];
for(int i=0;i<=cv;i++) {
recurse(n,ways,values,current+values[p]*i,p+1);
}
}
int main() {
int n;
cin>>n;
long long ways=0;
int values[] ={1,2,3};
len = sizeof(values)/sizeof(int);
recurse(n,ways,values);
cout<<ways;
}
The exception comes from (cv/=values[p];) line. Of course the shitty CodeBlocks never shows what the exception is. I'm sure its something easy to fix.