这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目地址: http://coder.buct.edu.cn/oj/Problem.aspx?pid=1040
高精~~~当然,打表也可以过的。
#include
#include
void fun(char* s,int n)
{
char* p=s;
int temp,jinwei;
for(*p=n+'0', jinwei=0;!(*p=='0'&&jinwei;==1);p++)
((temp = (*p-'0')*n+jinwei)>9)?(*(p+1)=temp%10+'0',jinwei=temp/10):(*(p+1)=temp+'0',jinwei=0);
*++p='1',*++p='\0';
_strrev(s);
}
int main()
{
char s[200];
printf("0\n1\n");
for (int i = 2; i <= 9; i++)
{
fun(s,i);
printf("%s\n", s);
}
return 0;
}