Faster input scanning

前端 未结 3 1357
清酒与你
清酒与你 2020-12-06 17:28

I am attempting to solve the SPOJ question that can be found here

Following is my solution:

package main

import \"fmt\"
import \"bufio\"
import \"os         


        
3条回答
  •  萌比男神i
    2020-12-06 17:59

    Try using bufio.Scanner (as suggested in the thread you mentioned):

    fmt.Scan(&n)
    fmt.Scan(&k)
    
    scanner := bufio.NewScanner(os.Stdin)
    for n > 0 {
        scanner.Scan()
        k, _ := strconv.Atoi(scanner.Text())
        ...
    

提交回复
热议问题