Computing Large Fibonacci Numbers Modulo 10000 Using Matrix Exponentiation

Problem Statement Given a non-negative integer n where 0 ≤ n ≤ 2×10^9, compute the n-th term of the Fibonacci sequence modulo 10000. The sequence is defined as F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. The input consists of multiple test cases, each containing a single integer n. Processing terminates when n = -1. Algorithmic ...

Posted on Thu, 13 Aug 2026 16:29:55 +0000 by neex1233

Algorithm Solutions for Competitive Programming Problems

Modular Division of Large Numbers This solution demonstrates how to perform division operations with large numbers under a specific modulus using Fermat's Little Theorem. The approach converts string representations of numbers into numerical arrays and applies modular arithmetic properties. #include <iostream> #include <cstdio> #inc ...

Posted on Tue, 14 Jul 2026 17:29:01 +0000 by modcar

NOIP 2013 Day 2 Algorithmic Problem Solutions

Wireless Network Coverage Optimization A city grid consists of 129 east-west streets and 129 north-south streets, forming intersections at integer coordinates (x, y) where 0 ≤ x, y ≤ 128. Some intersections host public venues, each with a known count of facilities. A single wireless transmitter must be placed such that its coverage area — an ax ...

Posted on Sun, 17 May 2026 20:09:04 +0000 by pod2oo5

Advanced Number Theory Algorithms and Applications

Number Theory 1.1 Chinese Remainder Theorem Problem Statement Given a system of congruences: \[ \begin{cases} x \equiv a_1 \pmod{b_1} \\ x \equiv a_2 \pmod{b_2} \\ \vdots \\ x \equiv a_n \pmod{b_n} \end{cases} \] Find the smallest positive integer solution for \(x\), where \(b_i\) (for \(i \in [1,n]\)) are pairwise coprime. Theoretical Analy ...

Posted on Sun, 17 May 2026 04:39:00 +0000 by xymbo

Minimum Spanning Tree Construction with Modular Arithmetic

Minimum Spanning Tree with Modular Edge Weights Prim's Algorithm Adaptation The classic Prim's algorithm builds a minimum spanning tree by starting from an initial vertex and repeatedly adding the minimum-weight edge connecting the tree to vertices outside it. For this problem, we adapt Prim's algorithm to handle edge weights computed as (a[i] ...

Posted on Sat, 16 May 2026 04:00:26 +0000 by dbchip2000

Lucas Theorem and Its Extended Application

Lucas Theorem Mathematical Statement Given prime $p$, the following congruence holds: $$\binom{n}{m} \equiv \binom{\lfloor n/p \rfloor}{\lfloor m/p \rfloor} \cdot \binom{n \bmod p}{m \bmod p} \pmod{p}$$ Proof Foundation Lemma 1 For prime $p$: $$\binom{p}{k} \equiv 0 \pmod{p} \text{ when } 0 < k < p$$ The numerator contains factor $p$, mak ...

Posted on Tue, 12 May 2026 18:23:17 +0000 by Moneypenny