Submission #693185
Source Code Expand
n, m, k = gets.chomp.split.map(&:to_i)
def pow_mod(n, k, m)
if k == 0
1
elsif k % 2 == 1
pow_mod(n, k - 1, m) * n % m
else
t = pow_mod(n, k / 2, m)
t * t % m
end
end
puts pow_mod(n, k, m)
Submission Info
| Submission Time | |
|---|---|
| Task | B - n^p mod m |
| User | ymdu |
| Language | Ruby (2.3.3) |
| Score | 100 |
| Code Size | 228 Byte |
| Status | AC |
| Exec Time | 19 ms |
| Memory | 1788 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 | 18 ms | 1788 KiB |
| 002.txt | AC | 17 ms | 1788 KiB |
| 003.txt | AC | 17 ms | 1788 KiB |
| 004.txt | AC | 17 ms | 1788 KiB |
| 005.txt | AC | 17 ms | 1788 KiB |
| 006.txt | AC | 17 ms | 1788 KiB |
| 007.txt | AC | 17 ms | 1788 KiB |
| 008.txt | AC | 17 ms | 1788 KiB |
| 009.txt | AC | 18 ms | 1788 KiB |
| 010.txt | AC | 18 ms | 1788 KiB |
| 011.txt | AC | 18 ms | 1788 KiB |
| 012.txt | AC | 18 ms | 1788 KiB |
| 013.txt | AC | 18 ms | 1788 KiB |
| 014.txt | AC | 18 ms | 1788 KiB |
| 015.txt | AC | 18 ms | 1788 KiB |
| 016.txt | AC | 18 ms | 1788 KiB |
| 017.txt | AC | 18 ms | 1788 KiB |
| 018.txt | AC | 18 ms | 1788 KiB |
| 019.txt | AC | 17 ms | 1788 KiB |
| 020.txt | AC | 17 ms | 1788 KiB |
| 021.txt | AC | 17 ms | 1788 KiB |
| 022.txt | AC | 18 ms | 1788 KiB |
| 023.txt | AC | 17 ms | 1788 KiB |
| 024.txt | AC | 17 ms | 1788 KiB |
| 025.txt | AC | 17 ms | 1788 KiB |
| 026.txt | AC | 17 ms | 1788 KiB |
| 027.txt | AC | 18 ms | 1788 KiB |
| sample_01.txt | AC | 18 ms | 1788 KiB |
| sample_02.txt | AC | 19 ms | 1788 KiB |