1 条题解
-
1Root (sky1231) LV 8 MOD @ 2018-05-26 19:52:35
#include <cmath> #include <ctime> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <algorithm> #include <vector> #include <deque> #include <set> #include <limits> #include <string> #include <sstream> using namespace std; namespace dts { typedef long long ll; ll ny(ll x,ll key) { if (x==1) return 1; else return -(key/x)*ny(key%x,key)%key; } ll a,b,key; void main() { while (~scanf("%lld%lld%lld",&a,&b,&key)) { ll p=ny(2,key); if (p<0) p+=((key-p)/key)*key; ll ans=(p*(((a-1)%key)*((b-1)%key)%key))%key; printf("%lld\n",ans); } } }; int main() { dts::main(); }
- 1