2 条题解

  • 0
    @ 2025-10-8 17:12:01

    第一棵树是颜色为 1 的一个节点,第二棵树是两个节点都为颜色 2 的一条链,第三棵树是颜色为 2 的一个节点。

    不难证明,没有能够画出更多树的方案。

    //搬运自 https://www.luogu.com.cn/problem/U482217
    //一句话题意:输出 min(TREE(N),x) 
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	ios::sync_with_stdio(0);cin.tie(0);
    	int n,x;cin>>n>>x;
    	int ans=1e9;
    	if(n==0)ans=0;
    	if(n==1)ans=1;
    	if(n==2)ans=3;
    	cout<<min(ans,x);
    	return 0;
    }
    
    • 0
      @ 2025-10-8 17:11:54

      样例解释:

      第一棵树是颜色为 11 的一个节点,第二棵树是两个节点都为颜色 22 的一条链,第三棵树是颜色为 22 的一个节点。

      不难证明,没有能够画出更多树的方案。

      对于 $100\%$ 的数据,$0\le N\le10^3$,$0\le x\le10^9$。


      //搬运自 https://www.luogu.com.cn/problem/U482217
      //一句话题意:输出 min(TREE(N),x) 
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	ios::sync_with_stdio(0);cin.tie(0);
      	int n,x;cin>>n>>x;
      	int ans=1e9;
      	if(n==0)ans=0;
      	if(n==1)ans=1;
      	if(n==2)ans=3;
      	cout<<min(ans,x);
      	return 0;
      }

      • 1

      *【入门题练习(难度:2):思维】数树

      信息

      ID
      6669
      时间
      1000ms
      内存
      128MiB
      难度
      10
      标签
      递交数
      8
      已通过
      4
      上传者