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

还是G++的问题,求助,哪位解释一下啊?

Posted by logics_space at 2009-03-29 22:17:41 on Problem 1285 and last updated at 2009-03-29 22:18:21
In Reply To:请问pku的G++不认识unsigned long long 吗,急!! Posted by:logics_space at 2009-03-27 21:03:25
上次是1285  这次是1715。。。。
pku 1715
同样的代码 G++超时,C++0ms  why??

#include<iostream>
using namespace std;
typedef long long ll;
char num[16]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
bool visit[16];
char ans[10], cnt;
ll A(ll n, ll m)
{
	ll ans = 1;
	for(int i = 1;  i <= m; i++)ans = ans*(n-i+1);
	return ans;
}
void find(ll n, int all, int now)
{ 
	if(now > all){ ans[cnt]=0; return; }
	int i = 15;
	while(n > A(16- now , all - now))
	{
		while(visit[i])i--;
		i--;
		n -= A(16- now , all - now);
	}
    while(visit[i])i--;
	ans[cnt++]=num[i];
	visit[i]=true;
	find(n, all, now+1 );
}
void search(ll n)
{ 
   int i= 8;
   while(n > 15*A(15, i-1) )
   {
	   n-=15* A(15,i-1);
       i--;
   }
   memset(visit, 0, sizeof(visit));
   cnt=0;
   find(n, i, 1);
}
int main()
{
	ll n;
	while(scanf("%lld",&n)!=EOF)
	{ 
		search(n);
		printf("%s\n",ans);
	}
}

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