这题刚开始自己推公式,推了好久并没有推出来,最后队友A的,据说是直接让n等于1,
然后用快速幂去求a得幂,然后直接用c去减这个值就是b,然后再用50个不同的n值去验证
,如果等式均成立,即使一对符合的值,个人不喜欢做这些感觉逻辑不是很严密的题,但是事实就是
这样,往往有些题逻辑不会很严密的让你感觉绝对对,因为由于学术有限,很多东西我们是很难验证的,
所以有时做题也需要猜想。
贴上队友代码:
#include<algorithm>
#include<iostream>
#include<limits.h>
#include<stdlib.h>
#include<string.h>
#include<complex>
#include<cstring>
#include<iomanip>
#include<stdio.h>
#include<bitset>
#include<cctype>
#include<math.h>
#include<string>
#include<time.h>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#define LL long long
#define ULL unsigned long long
using namespace std;
const int mod = 1000000007;
const double PI = acos(-1.0);
const double E = exp(1.0);
const int M = 200005;
LL Pow(LL x, LL n, int Mod)
{
LL ans = 1;
while( n ){
if(n & 1)
ans = (ans * x) % Mod;
x = (x * x) % Mod;
n /= 2;
}
return ans;
}
int main()
{
int t;
int c;
LL k1, k2, b1;
LL b;
int cas = 1;
while( cin >> c >> k1 >> b1 >> k2 ){
LL ans, n;
cout << "Case #" << cas++ << ":" << endl;
bool OK = 1;
for(LL i = 1; i < c; ++i){
LL temp = Pow(i, k1 + b1, c);
b = c - temp;
bool ok = 1;
for(LL j = 2; j < 50; ++j){
LL ans1 = Pow(i, k1 * j + b1, c);
LL ans2 = Pow(b, k2 * j - k2 + 1, c);
ans = (ans1 + ans2) % c;
//cout << ans1 << " fdafas" << ans2 << endl;
if(ans){
ok = 0;
break;
}
}
if(ok){
OK = 0;
cout << i << " " << b << endl;
}
}
if(OK)
puts("-1");
}
return 0;
}