杭电acm上的2062求解答Problem DescriptionConsider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexicography order. Your

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 20:41:23
杭电acm上的2062求解答ProblemDescriptionConsidertheaggregateAn={1,2,…,n}.Forexample,A1={1},A3={1,2,3}.Asubse

杭电acm上的2062求解答Problem DescriptionConsider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexicography order. Your
杭电acm上的2062求解答
Problem Description
Consider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexicography order. Your task is to find the m-th one.

Input
The input contains several test cases. Each test case consists of two numbers n and m ( 0< n

杭电acm上的2062求解答Problem DescriptionConsider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexicography order. Your
给你一个Testcase
Sample Input
11
Sample Output
20 71111
// 最小数远比你想想的复杂
#include <stdio.h>
int main()
{
int n,m,bg,i;
while(scanf("%d",&n)==1)
{
m=n;
bg = 1;
while(m!=0)
{
if(m<=7)
{
switch(m)
{
case 2:printf("1"); break;
case 3:printf("7"); break;
case 4:printf("4"); break;
case 5:printf("2"); break;
case 6:if(bg) printf("6"); else printf("0"); break;
case 7:printf("8"); break;
}
m=0;
}
else
{
switch(m%7)
{
case 1:printf("10"); m-=8; break;
case 2:printf("1"); m-=2; break;
case 3:
case 4:
case 5:if(bg) else break;
case 6:if(bg) printf("6"); else printf("0"); m-=6; break;
case 0:printf("8"); m-=7; break;
}
}
bg = 0;
}
printf(" ");
if (n%2==0)
{
for (i=0;i<n/2;i++)
printf("1");
}
else
{
printf("7");
for (i=0;i<(n-3)/2;i++)
printf("1");
}
printf("\n");
}
}