fork download
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "bufio"
  6. "os"
  7. "strings"
  8. "strconv"
  9. )
  10.  
  11. func main() {
  12. s := bufio.NewScanner(os.Stdin)
  13. for s.Scan() {
  14. line := strings.TrimSpace(s.Text())
  15. asStrings := strings.Split(line, " ")
  16. firstFactor, _ := strconv.ParseUint(asStrings[0], 10, 32)
  17. secondFactor, _ := strconv.ParseUint(asStrings[1], 10, 32)
  18. product := xorMultiply(uint(firstFactor), uint(secondFactor))
  19. fmt.Printf("%d@%d=%d\n", firstFactor, secondFactor, product)
  20. }
  21. }
  22.  
  23. func xorMultiply(a, b uint)(product uint) {
  24. for ; b != 0; a, b = a << 1, b >> 1 {
  25. product ^= (a * (b & 1))
  26. }
  27. return
  28. }
Success #stdin #stdout 0s 3100KB
stdin
5 9
1 2
9 0
6 1
3 3
2 5
7 9
13 11
5 17
14 13
19 1
63 63
stdout
5@9=45
1@2=2
9@0=0
6@1=6
3@3=5
2@5=10
7@9=63
13@11=127
5@17=85
14@13=70
19@1=19
63@63=1365