閱讀563 返回首頁    go 微軟 go windows


poj 1316 Self Numbers

用abcd的四重循環必然是最簡單的最直接的想法,而且9^4次循環並不大,完全可以接受

a+b+c+d+1000a+100b+10c+d = 1001a+101b+11c+2d


here is my code:


#include <stdio.h>

bool mark[10002]={false};

int main()
{
	int a,b,c,d,i;

	for(a=0;a<=9;a++)
		for(b=0;b<=9;b++)
			for(c=0;c<=9;c++)
				for(d=0;d<=9;d++)
				{
					i=1001*a+101*b+11*c+2*d;
					mark[i]=true;
				}

	for(i=1;i<10000;i++)
    {
		if(!mark[i])
			printf("%d\n",i);
    }
				
	return 0;
}


最後更新:2017-04-03 14:53:37

  上一篇:go matlab中函數的句柄
  下一篇:go [曆年IT筆試題]2014微軟校園招聘筆試試題