标签:blog io on div log as tt res return
given an integer ,find 最小长度minlen 的expression of integer, minlen 定义为多少个完全平方数相加
例如 14 = 1 + 4 + 9, minlen = 3
int MinExpressionInteger(int i) { int k = sqrt(i); if (k*k == i) return 1; int minLen = INT_MAX; while (k > sqrt(i / 2) - 1) { int len = 1 + MinExpressionInteger(i - k*k); if (minLen > len) minLen = len; k--; } return minLen; }
minlen of expression of integer
标签:blog io on div log as tt res return
原文地址:http://www.cnblogs.com/jobfindingnotes/p/4116625.html