Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

HROC101-Editorial

$
0
0

In this problem, the well known Fermat's Little Theorem is used to calculate the large power of numbers.

typedef long long ll; const ll MODULUS=1000000007; ll p(ll b, ll e, ll m) { ll c=1; while(e) { if(e&1LL) c=(cb)%m; e/=2LL; b=(bb)%m; } return c; } int main() { ll T, a, b, c, d; scanf("%lld", &T); while(T--) { scanf(" %lld %lld %lld %lld", &a, &b, &c, &d); ll ans1=p(a, b, MODULUS); ll ans2=p(c, d, MODULUS-1LL); ll ans=p(ans1, ans2, MODULUS); printf("%lld\n", ans); } return 0; }


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>