| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
觉得写得还可以,贴之#include<cstdio>
#include<cstring>
using namespace std;
const char *ch={"0123456789ABCDEF"};
const int W[8]={486486000,540540000,545945400,546436800,546477750,546480900,546481125,546481140};
int now;
bool f[16];
int getMax()
{
for(int i=15;i>=0;--i)
if(f[i])return i;
return -1;
}
int idx(int x,int next)
{
while(next--)
{
--x;
while(x>=0&&!f[x])--x;
}
return x;
}
int main()
{
int n;
while(scanf("%d",&n)==1)
{
memset(f,true,sizeof(f));
int loc=1,k;
for(k=0;n>W[k];++k);
if(k)n-=W[k-1];
for(int i=15;i>8+k;--i)loc*=i;
--n;
for(int i=k;i<8;++i)
{
now=idx(getMax(),n/loc);
f[now]=false;
n%=loc;
loc/=15-i+k;
printf("%c",ch[now]);
}
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator