# 3月12

1、

``````#include <iostream>
#include <cmath>
using namespace std;

bool isPrimer(int n)
{
for(int i=2;i<=sqrt(n);i++){
if(n%i == 0){
return 0;
}
}
return 1;
}
int main()
{
int s=0,n=1;
while(s!= 100002){
n++;
if(isPrimer(n)){
s++;
}

}
cout << n << endl;
return 0;
}``````

2、

``````#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e8+10;
int num[10]={1,2,3,4,5,6,7,8,9,10};
bool check(int num[10]){
for(int i=1;i<10;i++){
if(abs(num[i]-num[i-1])==1) return false;
}
return true;
}
int main()
{
int ans=0;
do{
if(check(num)) ans++;
}while(next_permutation(num,num+10));
cout<<ans;
return 0;
}``````

3、

``````include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define x first
#define y  second
const int N = 100010;
int cnt[N];
bool st[N];//记录每个帖子是否曾经是热帖
typedef pair<int, int > PII;
PII logs[N];
int main ()
{
int n, d, k;
scanf("%d%d%d", &n, &d, &k);

for(int i = 0; i < n; i++) scanf("%d%d", &logs[i].x, &logs[i].y);
sort(logs, logs + n);//记录完，然后时间排序

for(int i = 0, j = 0; i < n; i++)
{
int id = logs[i].y;
cnt[id] ++;
while(logs[i].x - logs[j].x >= d)
{
cnt[logs[j].y] --;
j++;
}
if(cnt[id] >= k) st[id] = true;
}
for(int i = 0; i < 100000; i++)
if(st[i]) cout << i << endl;
return 0;
}``````

...全文
9 回复 打赏 收藏 举报

3.9w+

2023-03-12 20:06

刷题！