Advertisement
Guest User

Untitled

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