Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

暴力方法,一个一个排除,0MS过了,大牛见笑

Posted by bhq at 2009-07-31 15:16:30 on Problem 1316 and last updated at 2009-07-31 15:20:06
//如果某数有generator,它一定可以拆成:i*1001 + j*101 + k*11 + m*2   0<=i,j,k,m<=9
//数组开到9*1001+9*101+9*11+9*2+1=10036

#include <iostream>
using namespace std;

int main()
{
	int selfnum[10036] = {0};
	for ( int i = 0 ; i < 10 ; ++ i )
		for ( int j = 0 ; j < 10 ; ++ j )
			for ( int k = 0 ; k < 10 ; ++ k )
				for ( int m = 0 ; m < 10 ; ++ m )
					selfnum[ i*1001 + j*101 + k*11 + m*2 ] = 1;
	for ( int i = 1 ; i <= 10000 ; ++ i  )
		if ( selfnum[i] == 0 )
			cout << i << endl;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator