Posts

Showing posts from December, 2018

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();    ...

Expansion of String-Skillrack

Image
JAVA Solution import java.util.*; public class Hello {     public static void main(String[] args) {         Scanner s = new Scanner(System.in);         String str = s.next();         int len = str.length()-1;         while(len>=0)         {             System.out.print(str.substring(len));             len--;         }     } }

Count of Punctuation-Skillrack

Image
Java Solution