File tree Expand file tree Collapse file tree 6 files changed +99
-6
lines changed
solution/3000-3099/3021.Alice and Bob Playing Flower Game Expand file tree Collapse file tree 6 files changed +99
-6
lines changed Original file line number Diff line number Diff line change 59
59
<!-- tabs:start -->
60
60
61
61
``` python
62
+ class Solution :
63
+ def flowerGame (self , n : int , m : int ) -> int :
64
+ count = (n + 1 ) // 2
65
+ tol = (m + 1 ) // 2
66
+ ecount = n // 2
67
+ etol = m // 2
68
+ return count * etol + ecount * tol
62
69
63
70
```
64
71
65
72
``` java
66
-
73
+ class Solution {
74
+ public long flowerGame (int n , int m ) {
75
+ long count = (n + 1 ) / 2 ;
76
+ long tol = (m + 1 ) / 2 ;
77
+ long ecount = n / 2 ;
78
+ long etol = m / 2 ;
79
+ return (count * etol + ecount * tol);
80
+ }
81
+ }
67
82
```
68
83
69
84
``` cpp
70
-
85
+ class Solution {
86
+ public:
87
+ long long flowerGame(int n, int m) {
88
+ long long count = (n + 1) / 2;
89
+ long long tol = (m + 1) / 2;
90
+ long long ecount = n / 2;
91
+ long long etol = m / 2;
92
+ return (count * etol + ecount * tol);
93
+ }
94
+ };
71
95
```
72
96
73
97
```go
74
-
98
+ func flowerGame(n int, m int) int64 {
99
+ count := int64((n + 1) / 2)
100
+ tol := int64((m + 1) / 2)
101
+ ecount := int64(n / 2)
102
+ etol := int64(m / 2)
103
+ return count*etol + ecount*tol
104
+ }
75
105
```
76
106
77
107
<!-- tabs: end -->
Original file line number Diff line number Diff line change 55
55
<!-- tabs:start -->
56
56
57
57
``` python
58
+ class Solution :
59
+ def flowerGame (self , n : int , m : int ) -> int :
60
+ count = (n + 1 ) // 2
61
+ tol = (m + 1 ) // 2
62
+ ecount = n // 2
63
+ etol = m // 2
64
+ return count * etol + ecount * tol
58
65
59
66
```
60
67
61
68
``` java
62
-
69
+ class Solution {
70
+ public long flowerGame (int n , int m ) {
71
+ long count = (n + 1 ) / 2 ;
72
+ long tol = (m + 1 ) / 2 ;
73
+ long ecount = n / 2 ;
74
+ long etol = m / 2 ;
75
+ return (count * etol + ecount * tol);
76
+ }
77
+ }
63
78
```
64
79
65
80
``` cpp
66
-
81
+ class Solution {
82
+ public:
83
+ long long flowerGame(int n, int m) {
84
+ long long count = (n + 1) / 2;
85
+ long long tol = (m + 1) / 2;
86
+ long long ecount = n / 2;
87
+ long long etol = m / 2;
88
+ return (count * etol + ecount * tol);
89
+ }
90
+ };
67
91
```
68
92
69
93
```go
70
-
94
+ func flowerGame(n int, m int) int64 {
95
+ count := int64((n + 1) / 2)
96
+ tol := int64((m + 1) / 2)
97
+ ecount := int64(n / 2)
98
+ etol := int64(m / 2)
99
+ return count*etol + ecount*tol
100
+ }
71
101
```
72
102
73
103
<!-- tabs: end -->
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public:
3
+ long long flowerGame (int n, int m) {
4
+ long long count = (n + 1 ) / 2 ;
5
+ long long tol = (m + 1 ) / 2 ;
6
+ long long ecount = n / 2 ;
7
+ long long etol = m / 2 ;
8
+ return (count * etol + ecount * tol);
9
+ }
10
+ };
Original file line number Diff line number Diff line change
1
+ func flowerGame (n int , m int ) int64 {
2
+ count := int64 ((n + 1 ) / 2 )
3
+ tol := int64 ((m + 1 ) / 2 )
4
+ ecount := int64 (n / 2 )
5
+ etol := int64 (m / 2 )
6
+ return count * etol + ecount * tol
7
+ }
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public long flowerGame (int n , int m ) {
3
+ long count = (n + 1 ) / 2 ;
4
+ long tol = (m + 1 ) / 2 ;
5
+ long ecount = n / 2 ;
6
+ long etol = m / 2 ;
7
+ return (count * etol + ecount * tol );
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def flowerGame (self , n : int , m : int ) -> int :
3
+ count = (n + 1 ) // 2
4
+ tol = (m + 1 ) // 2
5
+ ecount = n // 2
6
+ etol = m // 2
7
+ return count * etol + ecount * tol
You can’t perform that action at this time.
0 commit comments