Is BASH very slow?

后端 未结 4 1858
时光取名叫无心
时光取名叫无心 2021-01-18 03:14

I was solving this question on SPOJ - http://www.spoj.com/problems/ALICESIE/

What the question boils down to print (n+1)/2

This is my C code which passes in

4条回答
  •  悲哀的现实
    2021-01-18 03:52

    The shebang is not added.

    #!/bin/bash
    
    read test
    while (( test-- ))
    do
        read n
        echo "$(((n+1)/2))"
    done 
    

    This code I submitted, ran in 0.14 time in SPOJ and was accepted. I don't see any difference in the question code, except the shebang!!
    (For the reader)

提交回复
热议问题