|
|
back to boardHelp anybody Posted by ELDVN 20 Dec 2015 23:22 Wheres my wrong? help pleas #include <bits/stdc++.h> const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std; int n; int dp[maxn]={-1}; int calc(int n){ int res=n; dp[0]=0; if(dp[n] != -1) return dp[n]; for(int i=1; i*i <= n; i++){ res=min(res,1+calc(n-i*i)); } return dp[n]=res; }
int main(){ scanf("%d",&n); printf("%d\n", calc(n));
return 0; } Edited by author 20.12.2015 23:27 |
|
|