pI
unknown
c_cpp
a year ago
764 B
9
Indexable
#include<bits/stdc++.h>
#define int long long int
#define DBG(x) cout<<(#x " = ") <<x<<endl;
#define INF 1e15+9
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
const int N = 2828435;
const int MOD = 1e9+7; // 998244353;
typedef pair<int,int> P;
int dp[N], sm[N];
signed main(){
fastio
int n,m;
cin>>n>>m;
n = min(n+1,N);
for(int i=0;i<n;i++) sm[i] = 0, dp[i] = 0;
for(int i=1;i<n;i++){
for(int j=i;j<=n;j+=i){
sm[j]+=i;
}
}
for(int i=3;i<n;i++) dp[i] = dp[i-1] + 2*i-1 - sm[i];
int ans = 0;
for(int i=1;i<n;i++){
if(dp[i] <= m) ans++;
}
cout<<ans<<endl;
}Editor is loading...
Leave a Comment