Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pk5;
- import java.math.BigInteger;
- class PEC {
- BigInteger x,y;
- public PEC(String sx, String sy)
- {
- this.x=new BigInteger(sx);
- this.y=new BigInteger(sy);
- }
- public PEC()
- {
- this.x=new BigInteger("0");
- this.y=new BigInteger("0");
- }
- }
- public class PK5
- {
- public static BigInteger d (BigInteger e, BigInteger n)
- {
- BigInteger a, ap , s, sp, t, tp, r, m, qq, pq, c;
- BigInteger L1, L0;
- L0 = new BigInteger("0");
- L1 = new BigInteger("1");
- pq=n;
- if(e.compareTo(pq)>0)
- {
- m=e;
- }
- else
- {
- m=pq;
- n=e;
- }
- a=m;ap=n;s=L1;sp=L0;t=L0;tp=L1;
- while(ap.compareTo(L0)!=0)
- {
- qq=a.divide(ap);
- r=a;a=ap;ap=r.subtract(qq.multiply(ap));
- r=s;s=ap;sp=r.subtract(qq.multiply(sp));
- r=t;t=ap;tp=r.subtract(qq.multiply(tp));
- }
- c=a;
- if(t.compareTo(L0)>0)return t; else return t.add(pq);
- }
- public static BigInteger odw(BigInteger c, BigInteger n)
- {
- return d(c, n);
- }
- public static PEC DODPEC(PEC P1, PEC P2,
- BigInteger a, BigInteger b, BigInteger q)
- {
- BigInteger lam,r1,r2;
- PEC r=new PEC();
- if(((P1.x).compareTo(P2.x)!=0)||P1.y.compareTo(P2.y)!=0)
- {
- if((P1.x).compareTo(P2.x)!=0)
- {
- lam=P2.x.subtract((P1.x));
- lam=lam.mod(q);
- lam=odw(lam,q);
- lam=lam.multiply(((P2.y.subtract(P1.y))));
- lam=lam.mod(q);
- r1=lam.multiply(lam);
- r1=(r1.subtract(P1.x)).subtract(P2.x);
- r2=P1.x.subtract(r1);
- r2=r2.multiply(P1.y);
- r2=r2.subtract(P1.y);
- r.x=r1; r.y=r2;
- return r;
- }
- else
- {
- return new PEC ("-1","-1");
- }
- }
- else
- {
- }
- }
- public static void main(String[] args)
- {
- // TODO code application logic here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement