blob: fc61465293a4df7a5e4124aa352cfcd5e6965af3 (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package main
import "fmt"
const (
LIMITE = 0.99
)
func isBouncy( a int ) int {
if a < 101 {
return 0;
}
c, d := 0, 0
inc := 0
for c == d && a != 0 {
d = a % 10
a /= 10
c = a % 10
}
if c == d {
return 2;
}
if c < d {
inc = 1
for c <= d && a != 0 {
d = a % 10
a /= 10
c = a % 10
}
} else {
inc = -1
for c >= d && a != 0 {
d = a % 10
a /= 10
c = a % 10
}
}
if( a == 0 ) {
return inc
} else {
return 0
}
}
func main() {
tot := 0
i := 0
inc := 0
dec := 0
bon := 0
for i = 0 ; i < 10000 ; i++ {
if isBouncy(i) < 0 {
dec++
} else if isBouncy(i) == 0 {
bon++
} else if isBouncy(i) == 1 {
inc++
} else {
dec++
inc++
}
tot+=1.
}
fmt.Println(dec);
fmt.Println(inc);
fmt.Println(bon);
fmt.Println(tot-bon);
fmt.Println(tot);
}
|