好坑。。

一定要注意此题只是求数的多少。。没让求方案数。。
然后我第二次WA在了应该continue而不是break上。。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int n,a[200],tot;
int main(){
ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++){
//当前的数字为a[i]
for(int j=1;j<=n;j++){
if(j==i)continue;
for(int k=1;k<=n;k++){
if(k==i||k==j)continue;
if(a[i]==a[j]+a[k]){
tot++;
goto die;
}
}
}
die:;
}
cout<<tot<<endl;
while(1);
}

0 条评论

目前还没有评论...

信息

ID
1911
难度
6
分类
(无)
标签
递交数
16923
已通过
4475
通过率
26%
被复制
26
上传者