4 solutions

  • 1
    @ 2021-10-13 22:00:12

    P1030. 稳定性测试 题解

    题目回顾

    旅行者在蒙德闲逛,跑到了晨曦酒店来,发现这里有好多葡萄。旅行者看到那些交错的葡萄架,想起了小学老师讲过多边形的稳定性,聪明的他立马记起三角形最稳定。但是,旅行者很lazy,希望你帮忙算算这个问题。

    旅行者有很多木头,她随机给你三根木头以及他们的长度,你需要帮助他判断这三根木头是否可以形成稳定多边形。如果满足稳定性,就告诉旅行者 "Yes" (不包括引号),否则告诉他 "No"

    题目分析

    题目要求给定三个整数,并且测试是否稳定。就是判定是否为三角形,这没什么说的吧!

    我比较菜,下来查了一下“两边之和大于第三边” 与 “两边之差小于第三边” 这两者是互为逆否命题,所以写一个就可以了(别嘲笑我)

    可行代码

    #include <stdio.h>
    int main() {
        int T;
        scanf("%d", &T);
        while (T--) {
            int a, b, c;
            scanf("%d%d%d", &a, &b, &c);
            if(a + b > c && b + c > a && a + c > b){
            	printf("Yes\n");
    		}
    		else printf("No\n");
        }
        return 0;
    }
    

    END 有问题欢迎私聊Kirk,将不断完善题解

    • 0
      @ 2023-10-3 22:03:56
      这道题本身并不难,然而唯一需要注意的是,这是哪个OP写的题目?
      #include <bits/stdc++.h>
      using namespace std;
      int main(void)
      {
          int a,b,c,T;
          cin>>T;
          for (int i=1;i<=T;i++)
          {
              cin>>a>>b>>c;
              if ((a+b>c)&&(a+c>b)&&(c+b>a))
              {
                  cout<<"Yes"<<endl;
              }
              else
              {
                  cout<<"No"<<endl;
              }
          }
          return 0;
      }
      
      • 0
        @ 2022-4-5 1:43:21

        还好

        #include <iostream>
        using namespace std;
        int main()
        {
            int T = 0;
            cin >> T;
            while (T--)
            {   
                int m,n,p;
                cin >> m >> n >> p;
                if(m+n <= p || m+p <= n || p+n <= m)
                    cout << "No" << endl;
                else
                    cout << "Yes" << endl;
            }
            return 0;
        }
        
        • 0
          @ 2022-3-7 22:23:54
          //两边之和大于第三边或者两边之差小于第三边
          //这个条件互逆,写一个即可!
          #include <stdio.h>
          #include <algorithm>
          #include <math.h>
          using namespace std;
          int n,a[3];
          int main() {
              scanf("%d",&n);
              while(n--) {
                  scanf("%d%d%d",&a[0],&a[1],&a[2]);
                  sort(a,a+3);
                  if(a[0]+a[1]>a[2])
                      printf("Yes\n");
                  else
                      printf("No\n");
              }
              return 0;
          }
          
          • 1

          Information

          ID
          31
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          5
          Tags
          # Submissions
          496
          Accepted
          187
          Uploaded By