社区讨论
0分求调样例过了(改正闭关)
P1865A % B Problem参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mkjj3j6e
- 此快照首次捕获于
- 2026/01/18 17:23 上个月
- 此快照最后确认于
- 2026/01/22 09:30 4 周前
CPP
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define PII pair<int,int>
const int N=1e6+10;
int p[N];
bool f[N];
int a[N],k;
void solve(){
//freopen("pow.in","r",stdin);
//freopen("pow.out","w",stdout);
int n,m;
cin>>n>>m;
for(int i=2;i<=m;i++){
if(f[i]==0){
p[k++]=i;
for(int j=0;j<=m;j+=i){
f[j]=true;
}
}
}
while(n--){
int l,r;
cin>>l>>r;
if(l<1||r>m){
cout<<"Crossing the line";
continue;
}
int ans=0;
for(int i=l;i<=r;i++){
if(f[i]){
ans++;
}
}
cout<<ans<<endl;
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t;
t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...