HD 1058 Humber Numbers。本地都通过了最终还是WA了,莫名其妙

#include <iostream>
#include <fstream>
using namespace std;
int findMin(int a,int b)
{
	return a>=b?b:a;
}
int main()
{
	//ifstream cin("input.txt");
	int dp[5844],n=1;
	dp[1] = 1;
	int a=1,b=1,c=1,d=1;
	for (int i = 2 ; i<=5843 ; i++)
	{
		dp[i] = findMin(dp[a]*2,findMin(dp[b]*3,findMin(dp[c]*5,dp[d]*7)));
		if(dp[i] == dp[a]*2)
			a++;
		if(dp[i] == dp[b]*3)
			b++;
		if(dp[i] == dp[c]*5)
			c++;
		if(dp[i] == dp[d]*7)
			d++;
	}
	while (cin>>n&&n)
	{
		if (n%10 == 1 && n%100 != 11)
			cout<<"The "<<n<<"st humble number is "<<dp[n]<<endl;
		else if (n%10 == 2 && n%100 != 12)
			cout<<"The "<<n<<"nd humble number is "<<dp[n]<<endl;
		else if (n%10 == 3 && n% 100 != 13)
			cout<<"The "<<n<<"rd humble number is "<<dp[n]<<endl;
		else
			cout<<"The "<<n<<"th humble number is "<<dp[n]<<endl;

			
	}
	return 0;
}
WA了,哪位大神能指点一下错在哪儿了。

你可能感兴趣的:(HD 1058 Humber Numbers。本地都通过了最终还是WA了,莫名其妙)