Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. package pk5;
  2. import java.math.BigInteger;
  3.  
  4. class PEC {
  5. BigInteger x,y;
  6. public PEC(String sx, String sy)
  7. {
  8. this.x=new BigInteger(sx);
  9. this.y=new BigInteger(sy);
  10. }
  11. public PEC()
  12. {
  13. this.x=new BigInteger("0");
  14. this.y=new BigInteger("0");
  15. }
  16. }
  17. public class PK5
  18. {
  19. public static BigInteger d (BigInteger e, BigInteger n)
  20. {
  21. BigInteger a, ap , s, sp, t, tp, r, m, qq, pq, c;
  22. BigInteger L1, L0;
  23. L0 = new BigInteger("0");
  24. L1 = new BigInteger("1");
  25. pq=n;
  26. if(e.compareTo(pq)>0)
  27. {
  28. m=e;
  29. }
  30. else
  31. {
  32. m=pq;
  33. n=e;
  34. }
  35. a=m;ap=n;s=L1;sp=L0;t=L0;tp=L1;
  36. while(ap.compareTo(L0)!=0)
  37. {
  38. qq=a.divide(ap);
  39. r=a;a=ap;ap=r.subtract(qq.multiply(ap));
  40. r=s;s=ap;sp=r.subtract(qq.multiply(sp));
  41. r=t;t=ap;tp=r.subtract(qq.multiply(tp));
  42. }
  43. c=a;
  44. if(t.compareTo(L0)>0)return t; else return t.add(pq);
  45. }
  46.  
  47. public static BigInteger odw(BigInteger c, BigInteger n)
  48. {
  49. return d(c, n);
  50. }
  51. public static PEC DODPEC(PEC P1, PEC P2,
  52. BigInteger a, BigInteger b, BigInteger q)
  53. {
  54. BigInteger lam,r1,r2;
  55. PEC r=new PEC();
  56. if(((P1.x).compareTo(P2.x)!=0)||P1.y.compareTo(P2.y)!=0)
  57. {
  58. if((P1.x).compareTo(P2.x)!=0)
  59. {
  60. lam=P2.x.subtract((P1.x));
  61. lam=lam.mod(q);
  62. lam=odw(lam,q);
  63. lam=lam.multiply(((P2.y.subtract(P1.y))));
  64. lam=lam.mod(q);
  65. r1=lam.multiply(lam);
  66. r1=(r1.subtract(P1.x)).subtract(P2.x);
  67. r2=P1.x.subtract(r1);
  68. r2=r2.multiply(P1.y);
  69. r2=r2.subtract(P1.y);
  70. r.x=r1; r.y=r2;
  71. return r;
  72. }
  73. else
  74. {
  75. return new PEC ("-1","-1");
  76. }
  77. }
  78. else
  79. {
  80.  
  81. }
  82. }
  83.  
  84.  
  85.  
  86. public static void main(String[] args)
  87. {
  88. // TODO code application logic here
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement