SPOJ.com - Problem COINS

can someone help me to find out the bug??

Edit: for n=1e9, it is giving negative value.
Edit: link to my correct code: #include <bits/stdc++.h>using namespace std;long long f[1000001]={0};lon - Pastebin.com

Can’t find anything wrong.
Maybe try removing this and copy paste your code.

   #ifndef ONLINE_JUDGE
     freopen("ip.txt", "r", stdin);
     freopen("op.txt", "w", stdout);
   #endif