Posts

Showing posts with the label Hackerearth

Naughty Sid and SEV-Hackerearth

C Solution     #include <stdio.h>     #include<math.h>     #define PI 3.14159265     int main()     {        long long int t,i,a,H,o,h;        scanf("%lld",&t);        float x,y;        for(i=0;i<t;i++)        {            scanf("%lld %lld %lld",&a,&H,&o);            x=(1.0*H)/a;            y=tan(o*PI/180.0);            if(x>y)            {                h=ceil(H-(a*y)/2);        ...

Who wants to be a Millionaire?-Hackerearth

C++14 Solution #include <iostream> #include <stdio.h> using namespace std; int main() {  int test;  cin >> test;  while (test--) {     int n;     cin >> n;     printf ("%.6f\n", (float)(n-1)*1.0/(float)(n));  }     return 0; } Try this on Hackerearth   For more Hackerearth Problems

Monk's Choice Of Numbers-Hackerearth

JAVA Solution import java.util.*; class TestClass {     public static void main(String args[] ) throws Exception {         Scanner s = new Scanner(System.in);         int t = s.nextInt();         while(t!=0)         {             ArrayList<Integer>hs = new ArrayList<Integer>();             int n = s.nextInt(), k = s.nextInt(), i, count=0;             int ar[] = new int[n];             for(i=0;i<n;i++)             {                 ar[i] = s.nextInt();    ...

Interval Count - Hackerearth

C++ 14 Solution #include<iostream> using namespace std; int main() {       int t ;       cin>>t;         while(t!=0)         {             int count = 0,i, n ;long long int l , r ,tmp = 0;             cin>>n;             cin>>l>>r;             int p[n];             long long int l1[r+1]={0};             tmp = l;             for(i=0;i<n;i++)             {        ...

Nobita and String - Hackerearth

JAVA Solution import java.util.Scanner; class Test { public static void main(String [] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); while(t-- > 0) { String s = sc.nextLine(); String str[] = s.split(" "); for(int i = str.length - 1; i >= 0; i--) System.out.print(str[i] + " "); System.out.println(); } } } To try this on Hackerearth

Special Matrix - Hackerearth

C++ 14 Solution      #include<iostream>     using namespace std;     int main()     {          int t ;          cin>>t;             while(t!=0)             {                 int n;                 cin>>n;                 int mid = n/2+1;                 char ar[n+1][n+1];                 int i, j, k, l;         ...