This commit is contained in:
Zengtudor 2024-11-22 17:09:56 +08:00
parent 2ea60ba602
commit 211c7ea96b
8 changed files with 197 additions and 0 deletions

52
src/P3383/P3383.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll maxn{ll(1e8+5)};
ll n,q,tot,ans[maxn];
bitset<maxn> f;
void init(){
for(ll i{2};i<=n;i++){
if(!f[i]){
for(ll j{i+i};j<=n;j+=i){
f[j]=1;
}
}
}
}
struct CinNum{
char c;
ll n;
CinNum &operator>>(ll &num){
c=n=0;
while(!isdigit(c)){
c=getchar();
}
while(isdigit(c)){
n=n*10+c-'0';
c=getchar();
}
num=n;
return *this;
}
}cinn;
#define cin cinn
int main(){
iostream::sync_with_stdio(0)/*,cin.tie(0)*/,cout.tie(0);
cin>>n>>q;
init();
for(ll i{2};i<=n;i++){
if(!f[i]){
ans[++tot]=i;
}
}
while(q--){
ll k;
cin>>k;
cout<<ans[k]<<'\n';
}
}

110
src/P8865/P8865.cpp Normal file
View File

@ -0,0 +1,110 @@
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll maxn{ll(1e3+5)}, mod{998244353};
ll t,id,n,m,c,f,tmp,tor[maxn][maxn],totc,tou[maxn][maxn],ptor[maxn][maxn],totf,tod[maxn][maxn];
bitset<maxn> g[maxn];
string s;
template<class ...Args>
void pt(Args&&...args){
((cout<<std::forward<Args>(args)<<' '),...);
cout<<'\n';
}
template<class T,class P>
ostream&operator<<(ostream &os,const pair<T,P> &p){
cout<<"[DEBUG] "<<"( "<<p.first<<", "<<p.second<<" )";
return os;
}
void pnm(const ll (&a)[maxn][maxn]){
for(ll i{1};i<=n;i++){
cout<<"[DEBUG] ";
for(ll j{1};j<=m;j++){
cout<<a[i][j]<<' ';
}
cout<<'\n';
}
cout<<'\n';
}
int main(){
iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>t>>id;
while(t--){
cin>>n>>m>>c>>f;
totc=0;
totf=0;
// pt(n,m,c,f);
for(ll i{1};i<=n;i++){
cin>>s;
for(ll j{1};j<=m;j++){
g[i][j]=s[j-1]-'0';
// pt(g[i][j]);
}
}
// look right
for(ll i{1};i<=n;i++){
tor[i][m+1]=0;
for(ll j{m};j>=0;j--){
if(g[i][j]){
tor[i][j]=0;
ptor[i][j]=0;
}else{
tor[i][j]=tor[i][j+1]+1;
ptor[i][j]=ptor[i-1][j]+max(ll(0),tor[i][j]-1);
}
}
}
// pnm(tor);
// pnm(ptor);
//look up
for(ll j{1};j<=m;j++){
tou[0][j]=0;
for(ll i{1};i<=n;i++){
if(g[i][j]){
tou[i][j]=0;
}else{
tou[i][j]=tou[i-1][j]+1;
}
}
}
// pnm(tou);
//look down
for(ll j{1};j<=m;j++){
tod[n+1][j]=0;
}
for(ll i{n};i>=0;i--){
for(ll j{1};j<=m;j++){
if(g[i][j]){
tod[i][j]=0;
}else{
tod[i][j]=tod[i+1][j]+1;
}
}
}
// pnm(tod);
for(ll j{1};j<m;j++){
for(ll i{3};i<=n;i++){
if(
tor[i][j]>=2&&tou[i][j]>=3
){
// cout<<make_pair(i,j)<<'\n';
totc = (totc+(ptor[i-2][j]*(tor[i][j]-1))%mod)%mod;
if(tod[i][j]-1>0){
totf = (totf+(ptor[i-1][j]*(tor[i][j]-1)*(tod[i][j]-1))%mod)%mod;
}
// pt(totc,totf);
}
}
}
cout<<totc<<' '<<totf<<'\n';
}
}

View File

@ -0,0 +1 @@
4 2

View File

@ -0,0 +1,6 @@
1 0
4 3 1 1
001
010
000
000

View File

@ -0,0 +1 @@
36 18

View File

@ -0,0 +1,8 @@
1 0
6 6 1 1
000010
011000
000110
010000
011000
000000

View File

@ -0,0 +1 @@
114 514

18
src/P8865/plant/plant3.in Normal file
View File

@ -0,0 +1,18 @@
1 0
16 12 1 1
000000000001
011111111111
000000000011
011111111111
010011111111
010111100011
010011101111
011111100011
111111111111
000011111111
011111111111
000000111111
011111000111
011111011111
011111000111
011111011111