Created
December 7, 2012 03:33
-
-
Save tajo/4230544 to your computer and use it in GitHub Desktop.
Ponork
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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, §ions); | |
part = ponorks = 0; | |
while (sections--) { | |
scanf("%d\n", §ion); | |
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