思路
- 首先根据收益和风险的限制筛选出能买的基金的数量
。
- 则购买的方案总和为
。
- 在上一步的基础我们使用快速幂的方法计算。
代码实现
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, x, y;
cin >> n >> x >> y;
int cnt = 0;
int a, b;
for (int i = 0; i < n; i++)
{
cin >> a >> b;
if (a >= x && b <= y)
{
cnt++;
}
}
ll ans = 1;
int p = 2;
while (cnt)
{
if (cnt & 1)
{
ans = ans * p % 1000000007;
}
cnt >>= 1;
p = p * p % 1000000007;
}
cout << ans - 1;
return 0;
}