-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
4d67eb1
commit 447697a
Showing
15 changed files
with
4,037 additions
and
106 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
docs/assets/index-968fd8fc.css → docs/assets/index-118bae18.css
Large diffs are not rendered by default.
Oops, something went wrong.
184 changes: 92 additions & 92 deletions
184
docs/assets/index-21550645.js → docs/assets/index-74a2c48c.js
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,52 @@ | ||
/* | ||
* Calculates (d,X,Y) with d=gcd(a,b) and Xa+Yb=d | ||
*/ | ||
|
||
int mod(int mod_x, int mod_y) | ||
{ | ||
return mod_x - mod_y * (mod_x / mod_y); | ||
} | ||
|
||
int egcd(int egcd_out[3], int egcd_a, int egcd_b) | ||
{ | ||
if (mod(egcd_a, egcd_b) == 0) | ||
{ | ||
egcd_out[0] = egcd_b; | ||
egcd_out[1] = 0; | ||
egcd_out[2] = 1; | ||
} | ||
else | ||
{ | ||
int egcd_q = egcd_a / egcd_b; | ||
int egcd_r = egcd_a - egcd_q * egcd_b; | ||
int egcd_dxy[3]; | ||
|
||
egcd(egcd_dxy, egcd_b, egcd_r); | ||
|
||
egcd_out[0] = egcd_dxy[0]; | ||
egcd_out[1] = egcd_dxy[2]; | ||
egcd_out[2] = egcd_dxy[1] - egcd_dxy[2] * egcd_q; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
int a = read(); | ||
int b = read(); | ||
int dxy[3]; | ||
|
||
if (!(a >= b && b > 0)) | ||
{ | ||
return 1; | ||
} | ||
|
||
egcd(dxy, a, b); | ||
|
||
write(dxy[0]); | ||
write(dxy[1]); | ||
write(dxy[2]); | ||
|
||
return 0; | ||
} |
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,114 @@ | ||
FUNCTION mod : | ||
PARAM var0 | ||
PARAM var1 | ||
var2 := var0 / var1 | ||
var3 := var1 * var2 | ||
var4 := var0 - var3 | ||
RETURN var4 | ||
FUNCTION egcd : | ||
PARAM var5 | ||
PARAM var6 | ||
PARAM var7 | ||
ARG var7 | ||
ARG var6 | ||
var8 := CALL mod | ||
IF var8 == #0 GOTO label0 | ||
var9 := #0 | ||
GOTO label1 | ||
LABEL label0 : | ||
var9 := #1 | ||
LABEL label1 : | ||
IF var9 != #0 GOTO label2 | ||
var16 := var6 / var7 | ||
var18 := var16 * var7 | ||
var17 := var6 - var18 | ||
DEC var19 12 | ||
ARG var17 | ||
ARG var7 | ||
ARG &var19 | ||
CALL egcd | ||
var20 := #4 * #0 | ||
var21 := var5 + var20 | ||
var22 := #4 * #0 | ||
var23 := &var19 + var22 | ||
*var21 := *var23 | ||
var24 := #4 * #1 | ||
var25 := var5 + var24 | ||
var26 := #4 * #2 | ||
var27 := &var19 + var26 | ||
*var25 := *var27 | ||
var28 := #4 * #2 | ||
var29 := var5 + var28 | ||
var30 := #4 * #1 | ||
var31 := &var19 + var30 | ||
var32 := #4 * #2 | ||
var33 := &var19 + var32 | ||
var34 := *var33 * var16 | ||
var35 := *var31 - var34 | ||
*var29 := var35 | ||
GOTO label3 | ||
LABEL label2 : | ||
var10 := #4 * #0 | ||
var11 := var5 + var10 | ||
*var11 := var7 | ||
var12 := #4 * #1 | ||
var13 := var5 + var12 | ||
*var13 := #0 | ||
var14 := #4 * #2 | ||
var15 := var5 + var14 | ||
*var15 := #1 | ||
LABEL label3 : | ||
RETURN #0 | ||
FUNCTION main : | ||
READ var37 | ||
var36 := var37 | ||
READ var39 | ||
var38 := var39 | ||
DEC var40 12 | ||
IF var36 >= var38 GOTO label4 | ||
var41 := #0 | ||
GOTO label5 | ||
LABEL label4 : | ||
var41 := #1 | ||
LABEL label5 : | ||
IF var38 > #0 GOTO label6 | ||
var42 := #0 | ||
GOTO label7 | ||
LABEL label6 : | ||
var42 := #1 | ||
LABEL label7 : | ||
IF var41 != #0 GOTO label9 | ||
LABEL label10 : | ||
var43 := #0 | ||
GOTO label11 | ||
LABEL label9 : | ||
IF var42 != #0 GOTO label8 | ||
GOTO label10 | ||
LABEL label8 : | ||
var43 := #1 | ||
LABEL label11 : | ||
IF var43 != #0 GOTO label12 | ||
var44 := #1 | ||
GOTO label13 | ||
LABEL label12 : | ||
var44 := #0 | ||
LABEL label13 : | ||
IF var44 != #0 GOTO label14 | ||
GOTO label15 | ||
LABEL label14 : | ||
RETURN #1 | ||
LABEL label15 : | ||
ARG var38 | ||
ARG var36 | ||
ARG &var40 | ||
CALL egcd | ||
var45 := #4 * #0 | ||
var46 := &var40 + var45 | ||
WRITE *var46 | ||
var47 := #4 * #1 | ||
var48 := &var40 + var47 | ||
WRITE *var48 | ||
var49 := #4 * #2 | ||
var50 := &var40 + var49 | ||
WRITE *var50 | ||
RETURN #0 |
Oops, something went wrong.