UVa 11703 sqrt log sin (DP)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2750


不用加eps了,floor才是神器!


完整代码:

/*0.382s*/

#include<cstdio>
#include<cmath>
const int mod = 1000000;

int dp[mod + 1];

int main()
{
	int n, i ;
	dp[0] = 1;
	for (i = 1; i <= mod; ++i)
		dp[i] = (dp[(int)floor(i - sqrt(i))] + dp[(int)floor(log(i))] + dp[(int)floor(i * sin(i) * sin(i))]) % mod;
	while (scanf("%d", &n), n != -1)
		printf("%d\n", dp[n]);
}

你可能感兴趣的:(C++,ACM,uva)