diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a956e73..f37e711 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -5,37 +5,36 @@ name: Python package on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: build: - runs-on: ubuntu-latest strategy: matrix: python-version: [3.6, 3.7, 3.8] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install .[lint,test] - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Type check with mypy - run: | - mypy . - - name: Test with pytest - run: | - pytest + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[lint,test] + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Type check with mypy + run: | + mypy . --exclude example/ + - name: Test with pytest + run: | + pytest diff --git a/atcoder/math.py b/atcoder/math.py index c50ca88..7ad491f 100644 --- a/atcoder/math.py +++ b/atcoder/math.py @@ -16,15 +16,12 @@ def inv_mod(x: int, m: int) -> int: def crt(r: typing.List[int], m: typing.List[int]) -> typing.Tuple[int, int]: assert len(r) == len(m) - n = len(r) - # Contracts: 0 <= r0 < m0 r0 = 0 m0 = 1 - for i in range(n): - assert 1 <= m[i] - r1 = r[i] % m[i] - m1 = m[i] + for r1, m1 in zip(r, m): + assert 1 <= m1 + r1 %= m1 if m0 < m1: r0, r1 = r1, r0 m0, m1 = m1, m0