-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy path408.go
More file actions
39 lines (35 loc) · 648 Bytes
/
408.go
File metadata and controls
39 lines (35 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// UVa 408 - Uniform Generator
package main
import (
"fmt"
"os"
)
func main() {
in, _ := os.Open("408.in")
defer in.Close()
out, _ := os.Create("488.out")
defer out.Close()
var step, mod int
for {
if _, err := fmt.Fscanf(in, "%d%d", &step, &mod); err != nil {
break
}
appeared := make([]bool, mod)
appeared[0] = true
seed, cnt := 0, 1
for {
seed = (seed + step) % mod
if appeared[seed] {
break
}
cnt++
appeared[seed] = true
}
if fmt.Fprintf(out, "%10d%10d ", step, mod); cnt == mod {
fmt.Fprintln(out, "Good Choice")
} else {
fmt.Fprintln(out, "Bad Choice")
}
fmt.Fprintln(out)
}
}