#include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX 10010int c1[MAX], c2[MAX], num[110];/* 题目大意: 给你n种砝码,从1到n中砝码的重量和其中不能称出多少种重量,输出不能称出的总数和类别*/int main(){ int n; while( scanf("%d", &n)!=EOF ) { memset(num, 0, sizeof(num) ); memset(c1, 0, sizeof(c1) ); memset(c2, 0, sizeof(c2) ); int total = 0; for(int i=0; i<n; i++) //重量输入 {scanf("%d", &num[i]); total+=num[i];} //for(int i=0; i<=total; i++) //c1[i] = c2[i] = 0; c1[0] = 1; //第一个括号,重量为0的 for(int i=0; i<n; i++) { for(int j=0; j<=total; j++) { c2[j] |= c1[j]; //否能称得,自己砝码的重量 if(num[i] + j <=total) //重量和是否大于总重量 c2[j+num[i]] |= c1[j]; //重量和 c2[abs(j-num[i])] |= c1[j]; //重量差 } for(int j=0; j<=total; j++) //一次循环赋值 {c1[j] = c2[j]; c2[j] = 0;} } int count = 0; for(int i=0; i<=total; i++) //查找能否称得的重量 { if(!c1[i]) c2[count++] = i; } printf("%d\n", count); for(int i=0; i<count-1; i++) printf("%d ", c2[i]); if(count) printf("%d\n", c2[count-1]); } return 0;}/*Problem DescriptionNow you are asked to measure a dose of medicine with a balance and a number of weights. Certainly it is not always achievable. So you should find out the qualities which cannot be measured from the range [1,S]. S is the total quality of all the weights. InputThe input consists of multiple test cases, and each case begins with a single positive integer N (1<=N<=100) on a line by itself indicating the number of weights you have. Followed by N integers Ai (1<=i<=N), indicating the quality of each weight where 1<=Ai<=100. OutputFor each input set, you should first print a line specifying the number of qualities which cannot be measured. Then print another line which consists all the irrealizable qualities if the number is not zero. Sample Input31 2 439 2 1 Sample Output024 5*/