Time Limit Exceeded for "https://www.codechef.com/problems/INTEST"

package main

import (
“fmt”
)

func main(){
var i, numbers, div, input, count int64

fmt.Scanf("%d %d", &numbers, &div)
for ;i<numbers;i++ {
    fmt.Scanf("%d", &input)
    if input%div == 0{
        count += 1
    }
}
fmt.Println(count, "count")

}

Above is the solution of the problem, https://www.codechef.com/problems/INTEST . But after submission, I’m getting “Time Limit Exceeded”. Please help.

As the problem name says, the input for this problem is enormous and you need to use fast I/O operations to run your code within the time limit.

It seems that your I/O methods are not fast enough. Refer to the following link about using Go for competitive programming. It addresses the slow I/O issue.

http://byrd.im/competitive-go/

1 Like