TLE (6/10)
思路: 模拟整个过程
虽然TLE,但是在蓝桥杯官网上pass了
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL N = 1e6, INF = 0x7fffffff;
int n, m;
int luck[N];
int temp[N];
int main()
{
scanf("%d%d",&m,&n);
for(int i =1; i<=n; i++)
luck[i] = i;
int maxLuck = 1;
int cnt = 2;
LL left1 = n;
int del = 0;
int res = 0;
while(maxLuck<n)
{
if( m < maxLuck) res ++;//printf("luck num is:%d\n",maxLuck);
if(cnt == 2) maxLuck = luck[cnt];
else maxLuck = luck[cnt-1];
del = 0;
for(int i = cnt++; i <= left1; i++)
if( i % maxLuck == 0) luck[i] = INF, del++;//printf("delete idx: %d\n",i);
sort(luck,luck+n);
left1 -= del;
if(left1 <= 0)
{
break;
}
}
if(m < 2) printf("%d\n",res-1);
else printf("%d\n",res);
}