zoukankan      html  css  js  c++  java
  • HDU 6092 Rikka with Subset

    Rikka with Subset

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 739    Accepted Submission(s): 352


    Sample Input
    2
    2 3
    1 1 1 1
    3 3
    1 3 3 1
    Sample Output
    1 2
    1 1 1
    Hint
    In the first sample, $A$ is $[1,2]$. $A$ has four subsets $[],[1],[2],[1,2]$ and the sums of each subset are $0,1,2,3$. So $B=[1,1,1,1]$
     
    Source
     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstdlib>
     4 #include<cctype> 
     5 #include<cmath>
     6 #include<cstring>
     7 #include<map>
     8 #include<set>
     9 #include<queue>
    10 #include<vector>
    11 #include<algorithm>
    12 #include<string> 
    13 #define ll long long
    14 #define eps 1e-10
    15 #define LL unsigned long long
    16 using namespace std; 
    17 const int inf=0x3f3f3f3f;
    18 const int maxn=10000+10;
    19 const int mod=1e9+7;
    20 int a[maxn],b[maxn];
    21 int main()
    22 {
    23     int t,n,m;
    24     scanf("%d",&t);
    25     while(t--)
    26     {
    27         memset(a,0,sizeof(a));
    28         scanf("%d%d",&n,&m);
    29         for(int i=0;i<=m;i++)scanf("%d",&b[i]);
    30         for(int i=1;i<=n;i++){
    31             int flag=0;
    32             for(int j=1;j<=m;j++){
    33                 if(b[j]==0)continue;
    34                 if(b[j]&&flag==0){
    35                     flag=1;
    36                     a[i]=j;
    37                 }
    38                 b[j]=b[j]-b[j-a[i]];
    39             }
    40         }
    41         for(int i=1;i<=n;i++)
    42         printf("%s%d",i==1?"":" ",a[i]);
    43         printf("
    ");
    44     }
    45     return 0;
    46 }
     
  • 相关阅读:
    基于C/S模式的程序更新下载
    拓展方法
    主从级GridView
    using 的用法
    五大数据类型
    redis的主从复制原理及步骤
    redis的发布订阅
    redis的持久化
    redis的事务
    配置文件详解
  • 原文地址:https://www.cnblogs.com/Aa1039510121/p/7309314.html
Copyright © 2011-2022 走看看