forked from harrypotter0/algorithms-in-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f4f6cf
commit 3010074
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import math | ||
def readInts(): | ||
return list(map(int, raw_input().strip().split())) | ||
def readInt(): | ||
return int(raw_input()) | ||
def readIntsindex0(): | ||
return list(map(lambda x: int(x) - 1, input().split())) | ||
def readStrs(): | ||
return raw_input().split() | ||
def readStr(): | ||
return raw_input() | ||
|
||
|
||
for __ in range(readInt()): | ||
n = readInt() | ||
print n//2 | ||
|
||
|
||
''' | ||
Input: | ||
1 | ||
4 | ||
output: | ||
2 | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import math | ||
def readInts(): | ||
return list(map(int, raw_input().strip().split())) | ||
def readInt(): | ||
return int(raw_input()) | ||
def readIntsindex0(): | ||
return list(map(lambda x: int(x) - 1, input().split())) | ||
def readStrs(): | ||
return raw_input().split() | ||
def readStr(): | ||
return raw_input() | ||
|
||
for __ in range(readInt()): | ||
x,y=readInts() | ||
a=[] | ||
for i in range(x): | ||
a.append(readInts()) | ||
first=second=0 | ||
for i in range(x): | ||
for j in range(y): | ||
if((i+j)%2 == a[i][j]%2): | ||
first+=1 | ||
else: | ||
second+=1 | ||
print(min(first//2,second//2)) | ||
# print(first,second) | ||
|
||
''' | ||
Example input: | ||
2 | ||
1 2 | ||
3 2 | ||
3 3 | ||
1 0 1 | ||
1 0 0 | ||
1 0 1 | ||
Example output: | ||
0 | ||
1 | ||
''' |