Skip to content

Instantly share code, notes, and snippets.

@tajo
Created December 7, 2012 03:33
Show Gist options
  • Save tajo/4230544 to your computer and use it in GitHub Desktop.
Save tajo/4230544 to your computer and use it in GitHub Desktop.
Ponork
/*
* File: ponork.c
* Author: Vojta
*
* Created on December 13, 2011, 8:29 PM
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char** argv) {
int inputs, sections, length, ponorks, section;
double part, EPS = 1e-8;
scanf("%d\n", &inputs);
while (inputs--) {
scanf("%d %d\n", &length, &sections);
part = ponorks = 0;
while (sections--) {
scanf("%d\n", &section);
while ((part + length - EPS) <= section) {
ponorks++;
part += length;
}
ponorks++;
double zbytek = section - part;
part = sqrt(length * length - zbytek * zbytek);
if (zbytek + EPS < ((double) length / 2) && !sections) {
ponorks--;
}
}
printf("Strazny ujde %d ponorku.\n", ponorks);
}
return (EXIT_SUCCESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment