#include<iostream> using namespace std; bool check(int x){ for(int i = 2; i <=
x / i; i++) if(x % i == 0) return false; return true; } int main(){ int ans =
0; for(int i = 2; ; i++){ if(check(i)) ans++; if(ans == 100002) {
cout<<i<<endl; break; } } return 0; }

#include<iostream> using namespace std; const int N = 1000010; int n; int
primes[N], cnt; bool st[N]; void get_prime(int n){ for(int i = 2; i <= n; i++){
if(!st[i]){ primes[cnt++] = i; for(int j = i + i; j <= n; j += i) st[j] = true;
} } } int main(){ cin>>n; get_prime(n); cout<<cnt<<endl; return 0; }

primes[j] 一定是 i 的最小质因子
#include<iostream> using namespace std; const int N = 1000010; int n; int
primes[N], cnt; bool st[N]; void get_prime(int n){ for(int i = 2; i <= n; i++){
if(!st[i]) primes[cnt++] = i; for(int j = 0; primes[j] <= n / i; j++){
st[primes[j] * i] = true; if(i % primes[j] == 0) break; } } } int main(){
cin>>n; get_prime(n); cout<<cnt<<endl; return 0; }

#include<iostream> #include<algorithm> using namespace std; int main(){ int
a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int ans = 0; do{ bool falg = 0; for(int
i = 1; i < 10; i++) if(a[i] - 1 == a[i-1] || a[i-1] == a[i] + 1) falg = 1;
if(!falg) ans++; }while(next_permutation(a, a + 10)); printf("%d", ans); return
0; }

ts id

#include<algorithm> #include<iostream> using namespace std; #define x first
#define y second typedef pair<int, int> PII; const int N = 100010; int n, t, k;
PII logs[N]; int cnt[N]; bool st[N]; int main(){ scanf("%d%d%d", &n, &t, &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 >= t){ cnt[logs[j].y]--; j ++; } if(cnt[id] >= k)
st[id] = true; } for(int i = 0; i <= N; i++) if(st[i]) printf("%d\n", i);
return 0; }

#include<iostream> using namespace std; const int N = 10000; int n; int a[11];
int main(){ int a[22] = {1,1,1,1,1,1,1,3,3,1,1,4,6,4,1,1,5,10,10,5,1};
scanf("%d", &n); for(int i = 0; i <= 21; i++) if(a[i] == n){ cout<<i + 1<<endl;
break; } return 0; }

GitHub

Gitee