Baby Step Giant Step

download Baby Step Giant Step

If you can't read please download the document

description

Thuat toan buoc nho buoc lon viet tren ngon ngu lap trinh C chuan

Transcript of Baby Step Giant Step

// Baby_step1.cpp : Defines the entry point for the console application.#include "stdafx.h"#include #include #define INF 0xFFFFFFFUtypedef unsigned long long u64;// a^m mod n = modexp(a, m, n)unsigned modexp(unsigned b, unsigned e, unsigned m) {unsigned r;for (r = 1; e > 0; e >>= 1) {if (e & 1) r = (unsigned)(((u64)r * (u64)b) % (u64)m);b = (unsigned)(((u64)b * (u64)b) % (u64)m);}return r;}// a^i mod n = modmul(a0, a, n) with 0> 1) >= x) break;return x;}// Equality 2 arraysvoid equality(unsigned *a,unsigned *b,unsigned& c,unsigned& d,unsigned n,unsigned m){int i,j;for(i=0; i