现在的位置: 首页 > 综合 > 正文

hdu2674

2013年10月29日 ⁄ 综合 ⁄ 共 435字 ⁄ 字号 评论关闭

/*
分析:
    水,n>=2009直接输出0就行了。
    而事实上,当n>40开始,就可以开始输出0了。

                                           2012-05-09
*/

#include"stdio.h"
#include"string.h"
int main()
{
	char str[22];
	int i;
	int temp;
	int ans;
	while(scanf("%s",str)!=-1)
	{
		if(strlen(str)>3)
		{
			printf("0\n");
			continue;
		}


		temp=0;
		for(i=0;str[i];i++)
		{
			temp*=10;
			temp+=str[i]-'0';
		}
		/*****/         //15MS降到0MS
		if(temp>40)
		{
			printf("0\n");
			continue;
		}
		/*****/


		ans=1;
		for(i=2;i<=temp;i++)
		{
			ans*=i;
			ans%=2009;
			if(ans==0)	break;
		}


		printf("%d\n",ans);
	}
	return 0;
}

抱歉!评论已关闭.