1 条题解

  • 0
    @ 2026-5-19 0:04:24

    P9955 [USACO20DEC] Do You Know Your ABCs? B 题解

    解析

    a,b,cN+\because a,b,c\in \mathbb N^+

    aba+b+c\therefore a\leq b\leq \cdots \leq a+b+c

    aabb 就是给出的 77 个数中的最小值和次小值,cc 就是给出的最大值减去 a+ba+b

    代码

    #include<bits/stdc++.h>
    using namespace std;
    vector<int>v;
    int tmp;
    int main(){
    	cin.tie(0)->sync_with_stdio(0);
    	while(cin>>tmp){
    		v.push_back(tmp);
    	}
    	sort(v.begin(),v.end());
    	cout<<v[0]<<" "<<v[1]<<" "<<v[6]-v[0]-v[1];
    return 0;
    }
    
    

    题外话

    由于使用了 while 读入,在读完数之后请按 Ctrl+Z 强制终止读入。

    • 1

    信息

    ID
    7081
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    21
    已通过
    16
    上传者