宜信 银行坏账AC代码
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
const int mo = 100003;
//N^w-N(N-1)^(w-1)
long long int mi(long long int a,long long int b)
{ long long int ans = 1; a %= mo; while (b) { if (b & 1) ans = (ans*a)%mo; b >>= 1; a = (a*a)%mo; } return ans%mo;
}
int main() { long long int n, w; cin >> n >> w; long long int tmp = mi(n, w) - n*mi(n - 1, w - 1); while (tmp < 0) tmp += mo; cout << tmp<< endl; return 0;
}
这题三个点:
1.必须用long long,否则输入就有可能溢出
2.要用快速幂去算指数
3.最后输出的时候要考虑到负数的情况
