A - Memory
Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%lld & %llu
Description
小x和小h是好盆友,小h从小体弱多病,而且还非常健忘,于是把自己平时吃的n瓶药都给小x等人保管。
某一天由于雾都的pm2.5爆表,小h的慢性呼吸道疾病又发作了,但当小x掏出药瓶的时候,却发现了异常情况。
小x现在有n瓶药,每瓶药里面有无限个药片,每片药重量严格等于1克。但是,吹毛求疵的小x发现n瓶药中有2瓶药的每一片药片在重量上是不合格的,不合格的药片比正常药片轻0.1g。
小x现在有一个电子称(能够显示具体重量),由于时间紧急,小x决定从每瓶药中选择bi(1≤bi)个药片,称量它们的总和,并且只称一次,从而找出这两瓶不合格药的编号。
现在,请问最小字典序的序列b(由bi构成)是多少?
Input
一行一个整数n(2≤n≤52)
Output
一行n个数字,两两间用空格隔开,注意结尾没有空格。
Sample Input
3
Sample Output
1 2 3
直接暴力即可。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
int a[];
map<int,int> vis;
int main()
{
int n;
scanf("%d",&n);
a[] = ;
a[] = ;
vis[] = ;
if(n==) printf("1 1\n");
else
{
for(int i=;i<=n;i++)
{
int flag = ;
for(int j=a[i-]+;j<=&&!flag;j++)
{
int temp = j;
int flag1 = ;
for(int k=;k<i;k++)
{
if(vis[temp+a[k]])
{
flag1 = ;
break;
}
}
if(!flag1)
{
for(int k=;k<i;k++)
{
vis[temp+a[k]] = ;
}
flag = ;
a[i] = temp;
}
}
}
printf("%d",a[]);
for(int i=;i<=n;i++) printf(" %d",a[i]);
printf("\n");
}
return ;
}