这个最暴力的想法就是暴力模拟算出详细值加set去重
时间复杂度空间复杂度过大。
所以需要对值进行映射,再用set去重
映射方式很多,比较方便的是取对数
logn(a ^ b) = b * logn(a)
n可以取
e->log()
10->log10()
2->log2()
因为取了对数肯定会有误差
所以需要重载一下EPS
或者log2的精度比较高 可以不重载
/*
Zeolim - An AC a day keeps the bug away
*/
//#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <sstream>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 10;
const double eps = 0.0000001;
struct num
{
double val;
num(){}
num(double x)
{
val = x;
}
bool operator <(const num &b) const
{
return val + eps < b.val;
}
bool operator == (const num &b) const
{
return (val - b.val) <= eps;
}
};
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0); cout.tie(0);
//freopen("D://test.in", "r", stdin);
//freopen("D://test.out", "w", stdout);
set <num> S;
int m, n, a, b;
cin>>m>>n>>a>>b;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
S.insert( num ( double(j + b) * log10( double(a + i) ) ) );
}
}
cout<<S.size()<<endl;
return 0;
}