求大佬找一下错误之处(勿喷 谢谢)

P2141 [NOIP2014 普及组] 珠心算测验

。。题意是求有多少个数,而不是有多少种组合的方法。。
by mulberror @ 2018-10-29 14:41:40


也就是给定n个数,求这n个数中能组成几个数,而不是you多少种方法来组成这几个数
by 紫妹只有17岁 @ 2018-10-29 14:53:12


@[紫妹只有17岁](/space/show?uid=117316) DaLao讲一下怎么改嘛....
by 顾里 @ 2018-10-29 16:57:21


看一下我的代码吧~~语文不好~~ 主要是枚举的过程,看起来应该不难懂 ```cpp #include<bits/stdc++.h> using namespace std; const int N=50000; int ton[N]; bool used[N]; int n; int x; int res=0; int maxx=0; int main() { memset(used,false,sizeof(used));//表示某个数能否被表示 memset(ton,0,sizeof(ton)); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&x); ton[x]=1; maxx=max(maxx,x); } for(int i=1;i<=maxx;i++) for(int j=i+1;j<=maxx;j++) if(ton[i]==1&&ton[j]==1&&ton[i+j]==1&&used[i+j]==false) used[i+j]=true; for(int i=1;i<=maxx;i++) if(used[i]==true) res++; printf("%d\n",res); return 0; } ```
by 紫妹只有17岁 @ 2018-10-29 16:58:36


@[紫妹只有17岁](/space/show?uid=117316) 我竟然看懂了,,好厉害。。。。
by 顾里 @ 2018-10-29 17:05:31


@[顾里](/space/show?uid=140043) emmmm……~~那么私的代码应该可读~~
by 紫妹只有17岁 @ 2018-10-29 19:10:33


|