From 8cdda848bd2c6cc03657fb23dcae32311172370f Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Wed, 6 Jul 2016 14:06:01 +0800 Subject: [PATCH] =?UTF-8?q?Create=201193-more=5F=E5=86=B0=E5=B0=81.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CWOJ/1193-more_冰封.cpp | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 CWOJ/1193-more_冰封.cpp diff --git a/CWOJ/1193-more_冰封.cpp b/CWOJ/1193-more_冰封.cpp new file mode 100644 index 0000000..8b28e78 --- /dev/null +++ b/CWOJ/1193-more_冰封.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#define LL long long + +LL fast_plus(LL a, LL b, LL m) { + LL ret = 0; + while(b) { + if(b & 1) + ret = (ret + a) % m; + b >>= 1; + a = (a << 1) % m; + } + return ret; +} + +LL fast_pow(LL a, LL b, LL m) { + LL ret = 1; + while(b) { + if(b & 1) + ret = fast_plus(ret, a, m); + b >>= 1; + a = fast_plus(a, a, m); + } + return ret; +} + +int main() { + int i; + LL n, m, t, aa = 0; + char a[10005]; + ifstream fin; + fin.open("password.in"); + std::cin.sync_with_stdio(false); + std::cin>>a>>n>>m; + for(i = 0; i < strlen(a); i++) + aa = (aa * 10 + a[i] - '0') % m; + if(n == 1) + std::cout<