Run Code
|
API
|
Code Wall
|
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
child process
150116_MatrizOrdenada
1.c
1.3 Max threads
linear_search.c
Simple Fork
Nearly working
TruncatablePrime
CPTTRN_2
ATM