Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Building squares using smallest amount of matches
#include <stdio.h> #include <math.h> /* Problem: * what is the smallest number of matches needed to make n squares * with side=1 match? n is given by user through stdin. */ int main(void){ unsigned input, root, squared_root; register unsigned sum; scanf("%u", &input); root=sqrt(input); squared_root=root*root; sum=2*(squared_root+root); input-=squared_root; if(input>0) sum+=1+2*input+input/root; printf("%u\n", sum); return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
fgets and basic string manipulation
Vereinfachung
test
time clock and day count through seconds by ratneshgujarathi
AVANCE PREGUNTA 10 DE CADENAS
If Statements/Increments V1
C_141113_Primo01
The endless numbers.
B_141125_Burbuja
test
Please log in to post a comment.