3.2w+
社区成员
1\
#include <bits/stdc++.h>
#define mpr make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF = 0x3f3f3f3f;
const int N = 1e7 + 10;
int cnt;
ll primes[N];
bool st[N];
void get_primes(int n)
{
//枚举所有的数
for(ll i = 2;i <= n;i++)
{
if(!st[i]) primes[cnt++] = i;
//要的是质数,得在当前的质数范围中
for(int j = 0;primes[j]<= n/i;j++)
{
st[primes[j]* i] = 1;
if(i % primes[j] == 0) break;
}
}
}
//100002
void solve(){
get_primes(N);
cout << primes[100001];
}
void run()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main() {
run();
int t;
t = 1;
while(t--) {
solve();
}
return 0;
}
2\
#include <bits/stdc++.h>
#define mpr make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int a[] = {1,2,3,4,5,6,7,8,9,10};
ll cnt = 0;
void solve(){
do{
// for(int i = 0;i < 9;i++)
// {
// cout << a[i] <<" ";
// }
// cout <<endl;
cnt ++;
}while(next_permutation(a,a+10));
cout << cnt;
}
void run()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main() {
run();
int t;
t = 1;
while(t--) {
solve();
}
return 0;
}
3\脑子不在线,调试不出来
#include <bits/stdc++.h>
#define mpr make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int cnt[N];//统计帖子点赞数量
bool st[N];
struct Node{
int ts,id;
}node[N];
//按照时间排序
bool cmp(Node a,Node b)
{
// if(a.ts == b.ts) return a.id < b.id;
return a.ts < b.ts;
}
int n,d,k;
void solve(){
cin >> n >> d >> k;
for(int i = 0;i < n;i++)
{
cin >> node[i].ts >> node[i].id;
}
sort(node,node+n,cmp);
int j = 0;
for(int i = 0;i < n;i++)
{
//拿到当前时间下的帖子编号
cnt[node[i].id] ++;
//拿时间来做双指针 ,如果当前时间大于等于之前某个时间的差值d,那么这份比较久的帖子报废 了
while(node[i].ts - node[j].ts >= d)
{
cnt[node[j].id] --;
j++;
//统计是热帖的
if(cnt[node[i].id] >= k) st[node[i].id] = true;
}
}
for(int i = 0;i <= N;i++)
{
if(st[i]) cout << i<< endl;
}
}
void run()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main() {
run();
int t;
t = 1;
while(t--) {
solve();
}
return 0;
}