30求大神指点

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

#include<bits/stdc++.h> using namespace std; const int maxn=1000000; int t[4*maxn],g[4*maxn]; int n,a[4*maxn],ans; int main() { int i,j; scanf("%d",&n); for (i=1;i<=n;i++) { scanf("%d",&a[i]); g[a[i]]=1; } for (i=1;i<n;i++) { for (j=i+1;j<=n;j++) { t[a[i]+a[j]]++; } } for (i=1;i<=20000;i++) { if (t[i]>0&&g[i]) ans++; } printf("%d",ans); return 0; }
by yeshuo2018 @ 2018-10-16 19:22:14


希望更丰富的展现?使用Markdown
by 塔罗兰 @ 2018-10-16 19:22:20


@[尘封的你](/space/show?uid=91203) 这个可以a的 思路自己看吧
by yeshuo2018 @ 2018-10-16 19:22:42


@[yeshuo2018](/space/show?uid=122578) 谢谢
by 尘封的你 @ 2018-10-16 19:26:08


@[尘封的你](/space/show?uid=91203) 不客气
by yeshuo2018 @ 2018-10-16 19:26:41


|