-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
2 changed files
with
45 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,22 @@ | ||
|
||
# calculates a to the power of b | ||
function fastpow a b as | ||
let res = 1 | ||
let tmp = a | ||
while > b 0 do | ||
if == % b 2 1 then | ||
let res = * res tmp | ||
end if | ||
let tmp = * tmp tmp | ||
let b = / b 2 | ||
end while | ||
return res | ||
end function | ||
|
||
function main as | ||
let a = scan | ||
let b = scan | ||
let c = fastpow a b | ||
print a b c | ||
return 0 | ||
end function |
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,23 @@ | ||
|
||
function max_four a b c d as | ||
if > b a then | ||
let a = b | ||
end if | ||
if > c a then | ||
let a = c | ||
end if | ||
if > d a then | ||
let a = d | ||
end if | ||
return a | ||
end function | ||
|
||
function main as | ||
let vara = scan | ||
let varb = scan | ||
let varc = scan | ||
let vard = scan | ||
let mx = max_four vara varb varc vard | ||
print vara varb varc vard mx | ||
return 0 | ||
end function |