题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1024
因为n和m都到100了,所以直接快速幂硬算一定会爆炸,考虑直接对矩阵中的结果对2取对数,存到set里维护一下。还好精度没有爆炸。
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int maxn = 110; 5 int m, n, a, b; 6 set<double> s; 7 8 int main() { 9 // freopen("in", "r", stdin); 10 while(~scanf("%d%d%d%d",&m,&n,&a,&b)) { 11 s.clear(); 12 for(int i = 0; i < n; i++) { 13 for(int j = 0; j < m; j++) { 14 s.insert(log(pow(a+i,b+j)) / log(2)); 15 } 16 } 17 cout << s.size() << endl; 18 } 19 return 0; 20 }