跳到正文

个人记录

7月5日

Owen0130约 9 分钟
原文
文章信息与版本

文章信息

发布
2025年7月6日
收录
2025年12月12日
更新
2026年11月13日
篇幅
约 9 分钟

版本

  1. v1当前

周末舞会

###### 代码

include <iostream>

using namespace std;

int n,m,k;

int a[10005],b[10005];

int main(){

cin>>n>>m>>k;

for(int i=1;i<=n;i++) a[i]=i;

for(int j=1;j<=m;j++) b[j]=j;

for(int i=1;i<=k;i++){

cout<<a[i]<<” “<<b[i]<<endl;

a[n+i]=a[i];

b[m+i]=b[i];

return 0;

围圈报数

#include<bits/stdc++.h>

using namespace std;

int n,m,l=1,s=0,i=1;

int a[10005];

int main(){

cin>>n>>m;

while(s<n){

i++;

if(i>n) i=1;

if(a[i]!=1){

l++;

if(l==m){

cout<<i<<” ”;

a[i]=1;

l=0;

s++;

return 0;

[NOIP2004提高组]合并果子

#include<bits/stdc++.h>

using namespace std;

priority_queue<int,vector<int>,greater<int> > a;

int n,s;

int main(){

cin>>n;

for(int i=1;i<=n;i++){

int x;

cin>>x;

a.push(x);

for(int i=1;i<n;i++){

s+=a.top();

int x=a.top();

a.pop();

s+=a.top();

a.push(x+a.top());

a.pop();

cout<<s;

return 0;

【深基4.习5】求极差

#include<bits/stdc++.h>

using namespace std;

priority_queue<int,vector<int>,greater<int> > a;

int n;

int main(){

cin>>n;

for(int i=1;i<=n;i++){

int x;

cin>>x;

a.push(x);

int x=a.top();

for(int i=1;i<n;i++){

a.pop();

cout<<a.top()-x;

return 0;

[USACO09OPEN] CowLine S

用双端队列

#include<bits/stdc++.h>

using namespace std;

deque<int> a;

int n,j=1;

int main(){

cin>>n;

while(n—){

char x,y,o;

cin>>x>>y;

if(x==‘A’&&y==‘L’){

a.push_front(j);

j++;

if(x==‘A’&&y==‘R’){

a.push_back(j);

j++;

if(x==‘D’&&y==‘L’){

int k;

cin>>k;

while(k—) a.pop_front();

if(x==‘D’&&y==‘R’){

int k;

cin>>k;

while(k—) a.pop_back();

while(a.size()){

cout<<a.front()<<endl;

a.pop_front();

return 0;

作业

B3616

#include<bits/stdc++.h>

using namespace std;

queue<int> a;

int n,j=1;

int main(){

cin>>n;

while(n—){

int x;

cin>>x;

if(x==1){

int y;

cin>>y;

a.push(y);

if(x==2){

if(a.size()==0){

cout<<“ERR_CANNOT_POP”<<endl;

}else{

a.pop();

if(x==3){

if(a.size()==0){

cout<<“ERR_CANNOT_QUERY”<<endl;

}else{

cout<<a.front()<<endl;

if(x==4){

cout<<a.size()<<endl;

return 0;

占卜DIY

#include<bits/stdc++.h>

using namespace std;

deque<int> a[20];

int b[20],s;

char x;

int main(){

C++
for(int i=1;i<=13;i++)
	for(int j=1;j<=4;j++){
		cin>>x;
		if(x<='9'&&x>='1')a[i].push_back(x-'0');
		else if(x=='0')a[i].push_back(10);
		else if(x=='J')a[i].push_back(11);
		else if(x=='Q')a[i].push_back(12);
		else if(x=='K')a[i].push_back(13);
		else if(x=='A')a[i].push_back(1);
}
while(a[13].empty()==0) {
    int t=a[13].front();
	a[13].pop_front();
    while(t!=13) {
        b[t]++;
        if(b[t]>=4)s++;
        int p=a[t].back();
		a[t].pop_back();
		t=p;
    }
}
cout<<s;
return 0;

}

[GDOI2014] 世界杯

#include<bits/stdc++.h>

using namespace std;

int q1[100000],q2[100000],q3[100000];

double num[10000000];

int main(){

C++
priority_queue<int> a;
priority_queue<int> b;
priority_queue<int> c;
priority_queue<int> d;
int s,q,z,h,n,a1,b1,c1,d1;
cin>>s>>q>>z>>h;
for(int i=1;i<=s;i++){
	cin>>a1;
	a.push(a1);
}
for(int i=1;i<=q;i++){
	cin>>b1;
	b.push(b1);
}
for(int i=1;i<=z;i++){
	cin>>c1;
	c.push(c1);
}
for(int i=1;i<=h;i++){
	cin>>d1;
	d.push(d1);
}
cin>>n;
for(int i=1;i<=n;i++)
cin>>q1[i]>>q2[i]>>q3[i];
for(int i=1;i<=n;i++){
	int x=q1[i],y=q2[i],o=q3[i];
	num[i]+=a.top(); 
	a.pop();
	while(x){
		x--;
		num[i]+=b.top();
		b.pop();
	}
	while(y){
		y--;
		num[i]+=c.top();
		c.pop();
	}
	while(o){
		o--;
		num[i]+=d.top();
		d.pop();
	}
 printf("%.2lf\n",num[i]/(q1[i]+q2[i]+q3[i]+1));
} 
return 0; 

}

原文