cogs luogu 珠心算测试【noip2014 普及组】

1809. [NOIP2014]珠心算测试

★   输入文件: countb.in   输出文件: countb.out   简单对比
时间限制:1 s   内存限制:256 MB

【题目描述】

 

【提示】

输入输出文件名为countb 

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<cmath>
 5 
 6 using namespace std;
 7 const int N=110;
 8 
 9 int a[N];
10 
11 inline int read()
12 {
13     int x=0,f=1;
14     char c=getchar();
15     while(c<'0'||c>'9') {if(c=='-')f=-1; c=getchar();}
16     while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
17     return x*f;
18 }
19 
20 int main()
21 {
22     
23     freopen("countb.in","r",stdin);
24     freopen("countb.out","w",stdout);
25     int n=read();
26     for(int i=1;i<=n;i++)
27         a[i]=read();
28         
29     sort(a+1,a+n+1);
30     
31     int Answer=0;
32     for(int i=1;i<=n;i++)
33     {
34         bool flag=1;
35         for(int j=i-1;j>=1&&flag;j--)
36         {
37             for(int k=1;k<=i-1&&flag;k++)
38             {
39                 if(a[j]+a[k]==a[i]&&k!=j)
40                 {
41                     Answer++;
42                     flag=0;
43                 }
44             }
45         }
46     }
47     printf("%d",Answer);
48     return 0;
49     
50 }

 

转载于:https://www.cnblogs.com/lyqlyq/p/6903788.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值