1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /**************************************** @_@ Cat Got Bored *_* #_# *****************************************/ #include <bits/stdc++.h> #define loop(i,s,e) for(int i = s;i<=e;i++) //including end point #define pb(a) push_back(a) #define sqr(x) ((x)*(x)) #define CIN ios_base::sync_with_stdio(0); cin.tie(0); #define ll long long #define ull unsigned long long #define SZ(a) int(a.size()) #define read() freopen("input.txt", "r", stdin) #define write() freopen("output.txt", "w", stdout) #define ms(a,b) memset(a, b, sizeof(a)) #define all(v) v.begin(), v.end() #define PI acos(-1.0) #define pf printf #define sfi(a) scanf("%d",&a); #define sfii(a,b) scanf("%d %d",&a,&b); #define sfl(a) scanf("%lld",&a); #define sfll(a,b) scanf("%lld %lld",&a,&b); #define sful(a) scanf("%llu",&a); #define sfulul(a,b) scanf("%llu %llu",&a,&b); #define sful2(a,b) scanf("%llu %llu",&a,&b); // A little different #define sfc(a) scanf("%c",&a); #define sfs(a) scanf("%s",a); #define mp make_pair #define paii pair<int, int> #define padd pair<dd, dd> #define pall pair<ll, ll> #define fs first #define sc second #define CASE(t) printf("Case %d: ",++t) // t initialized 0 #define cCASE(t) cout<<"Case "<<++t<<": "; #define INF 1000000000 //10e9 #define EPS 1e-9 #define flc fflush(stdout); //For interactive programs , flush while using pf (that's why __c ) using namespace std; /* IDEA: A degenerate triangle is the "triangle" formed by three collinear points. It doesn't look like a triangle, it looks like a line segment. A parabola may be thought of as a degenerate ellipse with one vertex at an infinitely distant point. ______.___________ It's a degenerate triangle As sides are 3 , 5 , 8 3 + 5 = 8 */ int tri_type(int x,int y,int z) { int mx = max(max(x,y),z); int mn_sum = x+y+z - mx; if(mn_sum>mx) { return 1; // good triangle } else if(mn_sum==mx) { return 2; // Degenerate triangle } else { return 3; //IMPOSSIBLE to construct a triangle } } int main() { int a,b,c,d; sfii(a,b); sfii(c,d); //4C3 = 4 possible 3 tuples is a possibility for a triangle int pos1 = tri_type(a,b,c); int pos2 = tri_type(a,b,d); int pos3 = tri_type(a,c,d); int pos4 = tri_type(c,b,d); //First priority triangle 1 > Then Degenerate > Then Impossible if(pos1==1 || pos2==1 || pos3==1 || pos4==1) { cout<<"TRIANGLE"<<endl; } else if(pos1==2 || pos2==2 || pos3==2 || pos4==2) { cout<<"SEGMENT"<<endl; } else { cout<<"IMPOSSIBLE"<<endl; } return 0; } |
বুধবার, ১৫ জুন, ২০১৬
EASY CF 6 A
এতে সদস্যতা:
মন্তব্যগুলি পোস্ট করুন (Atom)
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন