目录https://www.luogu.com.cn/training/103#problems
成都创新互联网站建设10年坚持,服务企业网站设计、成都响应式网站建设公司等网站建设服务。上千企业的合作经验,帮助我们为服务企业不断提升价值。为企业建设开发网站和维护,主推个性化定制型网站设计
#includeusing namespace std;
const int N=1e5+10;
int a[N],n;
int main(void)
{cin>>n;
for(int i=0;i>a[i];
for(int i=0;iint cnt=0;
for(int j=0;j if(a[i]>a[j]) cnt++;
}
cout<
P1427 小鱼的数字游戏#includeusing namespace std;
const int N=1e5+10;
int a[N],cnt;
int main(void)
{while(cin>>a[cnt++])
if(a[cnt-1]==0) break;
for(int i=cnt-2;i>=0;i--) cout<
P5727 【深基5.例3】冰雹猜想#includeusing namespace std;
int main(void)
{int n; cin>>n;
vectorve; ve.push_back(n);
while(n!=1)
{if(n%2==0) n=n/2;
else n=n*3+1;
ve.push_back(n);
}
for(int i=ve.size()-1;i>=0;i--) cout<
P1047 [NOIP2005 普及组] 校门外的树#includeusing namespace std;
const int N=1e5+10;
int a[N],n,m;
int main(void)
{cin>>n>>m;
while(m--)
{int l,r; cin>>l>>r;
l++,r++;
a[l]+=1,a[r+1]-=1;
}
int ans=n+1;
for(int i=1;i<=n+1;i++)
{a[i]+=a[i-1];
if(a[i]) ans--;
}
cout<
P5728 【深基5.例5】旗鼓相当的对手#includeusing namespace std;
const int N=1e4+10;
int a[N],b[N],c[N];
int n,cnt;
int main(void)
{cin>>n;
for(int i=0;i>a[i]>>b[i]>>c[i];
for(int i=0;ifor(int j=i+1;j int flag=1;
if(abs(a[i]-a[j])>5) flag=0;
if(abs(b[i]-b[j])>5) flag=0;
if(abs(c[i]-c[j])>5) flag=0;
if(abs(a[i]+b[i]+c[i]-a[j]-b[j]-c[j])>10) flag=0;
if(flag) cnt++;
}
}
cout<
P5729 【深基5.例7】工艺品制作#includeusing namespace std;
const int N=110;
int a[N][N][N],n,m,k;
int t;
int main(void)
{cin>>n>>m>>k;
cin>>t;
while(t--)
{int l1,l2,l3,r1,r2,r3; cin>>l1>>l2>>l3>>r1>>r2>>r3;
for(int i=l1;i<=r1;i++)
for(int j=l2;j<=r2;j++)
for(int z=l3;z<=r3;z++)
a[i][j][z]=1;
}
int cnt=n*m*k;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
for(int z=1;z<=k;z++) if(a[i][j][z]) cnt--;
cout<
P2550 [AHOI2001]彩票摇奖#includeusing namespace std;
const int N=1e3+10;
int a[N],st[N],ans[N],n;
int main(void)
{cin>>n;
for(int i=0;i<7;i++) cin>>a[i],st[a[i]]=1;
while(n--)
{int cnt=0;
for(int i=0;i<7;i++)
{ int x; cin>>x;
if(st[x]) cnt++;
}
ans[cnt]++;
}
for(int i=7;i>=1;i--) cout<
P2615 [NOIP2015 提高组] 神奇的幻方#includeusing namespace std;
const int N=45;
int a[N][N],n;
int main(void)
{cin>>n;
a[0][n/2]=1;
int k=2,x=0,y=n/2;
while(k<=n*n)
{if( x==0 && y!=(n-1) )
{ x=n-1,y++;
a[x][y]=k++;
}else if( x!=0 && y==(n-1) )
{ x--,y=0;
a[x][y]=k++;
}else if( x==0 && y==(n-1))
{ x++;
a[x][y]=k++;
}else if( x!=0 && y!=(n-1) && !a[x-1][y+1])
{ x--,y++;
a[x][y]=k++;
}else
{ x++;
a[x][y]=k++;
}
}
for(int i=0;ifor(int j=0;j
P5730 【深基5.例10】显示屏#includeusing namespace std;
string a[10][5]={{"XXX","X.X","X.X","X.X","XXX"},//0
{"..X","..X","..X","..X","..X"},//1
{"XXX","..X","XXX","X..","XXX"},//2
{"XXX","..X","XXX","..X","XXX"},//3
{"X.X","X.X","XXX","..X","..X"},//4
{"XXX","X..","XXX","..X","XXX"},//5
{"XXX","X..","XXX","X.X","XXX"},//6
{"XXX","..X","..X","..X","..X"},//7
{"XXX","X.X","XXX","X.X","XXX"},//8
{"XXX","X.X","XXX","..X","XXX"}//9
};//2
int main(void)
{int n; cin>>n;
string s; cin>>s;
vectorve;
for(int i=0;i<5;i++)
{string temp;
for(int j=0;j temp=temp+a[s[j]-'0'][i];
if(j!=(s.size()-1)) temp+='.';
}
ve.push_back(temp);
}
for(int i=0;i
P1554 梦中的统计#includeusing namespace std;
int a[15];
int main(void)
{int l,r; cin>>l>>r;
for(int i=l;i<=r;i++)
{int temp=i;
while(temp)
{ a[temp%10]++;
temp/=10;
}
}
for(int i=0;i<=9;i++) cout<
P2141 [NOIP2014 普及组] 珠心算测验#includeusing namespace std;
int a[105],n;
int main(void)
{cin>>n;
for(int i=0;i>a[i];
int cnt=0;
for(int i=0;iint flag=0;
for(int j=0;j
#includeusing namespace std;
const int N=150;
int a[N],n;
mapmp;
int main(void)
{cin>>n;
for(int i=0;i>a[i],mp[a[i]]++;
int ans=0;
for(int i=0;i
P1614 爱与愁的心痛#includeusing namespace std;
const int N=1e5+10;
int a[N],s[N],n,m;
int main(void)
{cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i],s[i]=s[i-1]+a[i];
int ans=1e9;
for(int i=1;i+m-1<=n;i++)
{int l=i,r=i+m-1;
ans=min(ans,s[r]-s[l-1]);
}
cout<
P2911 [USACO08OCT]Bovine Bones G#includeusing namespace std;
int a[305],n,m,k;
int main(void)
{cin>>n>>m>>k;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
for(int z=1;z<=k;z++)
a[i+j+z]++;
int index=0,ans=0;
for(int i=1;i<=n+m+k;i++) if(a[i]>ans) ans=a[i],index=i;
cout<
P1161 开灯#includeusing namespace std;
const int N=2*1e6+10;
int st[N],n;
int main(void)
{cin>>n;
while(n--)
{double a;
int t; cin>>a>>t;
for(int i=1;i<=t;i++)
{ st[(int)(a*i)]^=1;
}
}
for(int i=1;iif(st[i])
{ cout<
P5731 【深基5.习6】蛇形方阵#includeusing namespace std;
int a[15][15],n;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(void)
{cin>>n;
int stx=0,sty=0,d=0,k=1;
while(k<=n*n)
{a[stx][sty]=k++;
int tempx=stx+dx[d],tempy=sty+dy[d];
if(tempx<0||tempx>=n||tempy<0||tempy>=n||a[tempx][tempy]) d=(d+1)%4;
stx=stx+dx[d],sty=sty+dy[d];
}
for(int i=0;ifor(int j=0;j
P5732 【深基5.习7】杨辉三角#includeusing namespace std;
int a[25][25],n;
int main(void)
{cin>>n;
a[1][1]=1;
for(int i=2;i<=n;i++)
for(int j=1;j<=i;j++)
a[i][j]=a[i-1][j]+a[i-1][j-1];
for(int i=1;i<=n;i++)
{for(int j=1;j<=i;j++) cout<
P1789 【Mc生存】插火把#includeusing namespace std;
const int N=150;
int a[N][N],n,m,k;
int main(void)
{cin>>n>>m>>k;
while(m--)
{int x,y; cin>>x>>y;
for(int i=max(1,x-2);i<=min(n,x+2);i++) a[i][y]=1;
for(int i=max(1,y-2);i<=min(n,y+2);i++) a[x][i]=1;
for(int i=x-1;i<=x+1;i++)
for(int j=y-1;j<=y+1;j++)
if(i>=1&&i<=n&&j>=1&&j<=n) a[i][j]=1;
}
while(k--)
{int x,y; cin>>x>>y;
for(int i=x-2;i<=x+2;i++)
for(int j=y-2;j<=y+2;j++)
if(i>=1&&i<=n&&j>=1&&j<=n) a[i][j]=1;
}
int cnt=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++) if(!a[i][j]) cnt++;
cout<
P1319 压缩技术#includeusing namespace std;
int main(void)
{int n,x,flag=0; cin>>n;
string s;
while(cin>>x)
{for(int i=1;i<=x;i++) s+=to_string(flag);
flag=flag^1;
}
for(int i=0;icout<
P1320 压缩技术(续集版)#includeusing namespace std;
string a,b;
int main(void)
{while(cin>>b) a+=b;
cout<int j=i;
while(j+1
P1205 [USACO1.2] 方块转换 Transformations#includeusing namespace std;
const int N=25;
string s[N];
int n,a[N][N],b[N][N],c[N][N],d[N][N];
int f1()
{for(int i=0;ifor(int i=0;ifor(int i=0;imemcpy(c,a,sizeof c);
for(int i=0;imemcpy(c,a,sizeof c);
for(int i=0;i0};
memcpy(temp,a,sizeof a);
memcpy(a,c,sizeof a);
if(f1()|| f2() || f3())
{memcpy(a,temp,sizeof a);
return 1;
}
memcpy(a,temp,sizeof a);
return 0;
}
int f6()
{for(int i=0;icin>>n;
for(int i=0;icin>>s[i];
for(int j=0;jcin>>s[i];
for(int j=0;j
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧