Submission #694238
Source Code Expand
function main()
N = io.read "n"
M = io.read "n"
P = io.read "n"
print(powMod(N, P, M))
end
function powMod(n, p, m)
local r = 1
while p > 0 do
if p & 1 == 1 then
r = (r * n) % m
end
n = (n * n) % m
p = p >> 1
end
return r
end
main()
Submission Info
| Submission Time | |
|---|---|
| Task | B - n^p mod m |
| User | bovini |
| Language | Lua (5.3.2) |
| Score | 100 |
| Code Size | 331 Byte |
| Status | AC |
| Exec Time | 12 ms |
| Memory | 760 KiB |
Judge Result
| Set Name | Sample | All | ||
|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||
| Status | AC |
|
| Set Name | Test Cases |
|---|---|
| Sample | |
| All | 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 001.txt | AC | 12 ms | 760 KiB |
| 002.txt | AC | 4 ms | 256 KiB |
| 003.txt | AC | 4 ms | 256 KiB |
| 004.txt | AC | 4 ms | 256 KiB |
| 005.txt | AC | 4 ms | 256 KiB |
| 006.txt | AC | 5 ms | 256 KiB |
| 007.txt | AC | 4 ms | 256 KiB |
| 008.txt | AC | 4 ms | 256 KiB |
| 009.txt | AC | 4 ms | 256 KiB |
| 010.txt | AC | 4 ms | 256 KiB |
| 011.txt | AC | 4 ms | 256 KiB |
| 012.txt | AC | 4 ms | 256 KiB |
| 013.txt | AC | 4 ms | 256 KiB |
| 014.txt | AC | 4 ms | 256 KiB |
| 015.txt | AC | 4 ms | 256 KiB |
| 016.txt | AC | 4 ms | 256 KiB |
| 017.txt | AC | 5 ms | 256 KiB |
| 018.txt | AC | 4 ms | 256 KiB |
| 019.txt | AC | 4 ms | 256 KiB |
| 020.txt | AC | 4 ms | 256 KiB |
| 021.txt | AC | 4 ms | 256 KiB |
| 022.txt | AC | 4 ms | 256 KiB |
| 023.txt | AC | 4 ms | 256 KiB |
| 024.txt | AC | 4 ms | 256 KiB |
| 025.txt | AC | 4 ms | 256 KiB |
| 026.txt | AC | 4 ms | 256 KiB |
| 027.txt | AC | 4 ms | 256 KiB |
| sample_01.txt | AC | 4 ms | 256 KiB |
| sample_02.txt | AC | 4 ms | 256 KiB |