1422A - Fence - CodeForces Solution


geometry math *800

Please click on ads to support us..

Python Code:

import math as m
t = int(input())
for _ in range(t):
    a,b,c = list(map(int,input().split()))
    Min = min(a,b,c)
    Max = max(a,b,c)
    x = Max-Min
    d = m.ceil(m.sqrt(Min**2+x**2))
    print(d)

C++ Code:

                //~~~  Shree Ganeshaay Naamh ~~~//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
const double eps = 1e-6;
const ll M=1e9+7;
#define pb emplace_back
#define pbs push_back
#define ff first
#define ss second
#define mpp make_pair
#define srt(x) sort(x.begin(), x.end())
#define srtg(x) sort(x.begin(), x.end(),greater<>())
#define all(v) v.begin(),v.end()
#define pree(x) cout << fixed << setprecision(10) << x
#define l_b lower_bound
#define u_b upper_bound


// Sieve code
/*
const ll N= 1000000;
bool sieve[N+1];

void createsieve(){
    sieve[0] = sieve[1] = true;
    sieve[2]=false;
    for(ll i=2;i*i<N;i++){
          if(sieve[i]==false){
        for(ll j=i*i;j<N;j=j+i){
            sieve[j] = true;
        }
      }
    } 
    
}
*/

bool ispal(string s){
    
 ll n = s.length();

 for(ll i=0;i<n/2;i++){
     if(s[i]!=s[n-i-1]){
         return false;
     }
 }
   return true;
}

ll andOperator(ll n, ll m){

  ll answer = 0;

  for(ll i = 63 ;i>=0; i--){
      if((m&(1ll<<i))!=(n&(1ll<<i))){
         break;
      }else{
         answer |= (n&(1ll<<i));
      }
  }
  return answer;
}

ll power(ll a,ll b,ll p){
    ll res=1;
    if(a==0){
        return 0;
    }
    while(b>0){
        if(b%2!=0){
            res=(res*a)%p;
        }
        b=b/2;
        a=(a*a)%p;
    }
    return res;
}

int main(){
  
    
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
  ll t;
  cin>>t;
  while(t--){
  
  ll a,b,c;
  cin>>a>>b>>c;
  ll d =max(a,max(b,c));
  if(d==1){
    cout<<1<<"\n";
  }else{
  cout<<d-(ll)1<<"\n";
  }

  }

  return 0;
}


Comments

Submit
0 Comments
More Questions

762C - Two strings
802M - April Fools' Problem (easy)
577B - Modulo Sum
1555B - Two Tables
1686A - Everything Everywhere All But One
1469B - Red and Blue
1257B - Magic Stick
18C - Stripe
1203B - Equal Rectangles
1536A - Omkar and Bad Story
1509A - Average Height
1506C - Double-ended Strings
340A - The Wall
377A - Maze
500A - New Year Transportation
908D - New Year and Arbitrary Arrangement
199A - Hexadecimal's theorem
519C - A and B and Team Training
631A - Interview
961B - Lecture Sleep
522A - Reposts
1166D - Cute Sequences
1176A - Divide it
1527A - And Then There Were K
1618E - Singers' Tour
1560B - Who's Opposite
182B - Vasya's Calendar
934A - A Compatible Pair
1618F - Reverse
1684C - Column Swapping