Registrations for the November 2021 System Design Cohort are now open Enroll Today

HANGOVER Solution



#include <stdio.h>

int main ( int argc , char  *argv[] ) {

	double sum = 0;
	double n;

	scanf("%lf" , &n);

	while ( n != 0 ) {
		double i = 2;
		for ( i = 2 , sum = 0 ; sum <= n ; i++ ) {
			sum += 1/i;
		}

		printf("%d card(s)\n" , ((int) i) - 2);
		scanf("%lf" , &n);

	}

	return 0;
}

470+ Competitive Programming Solutions

If you like what you read subscribe to my newsletter.

I write essays on various engineering topics and share it through my weekly newsletter 👇