跳到正文

Zsj0411

1133796

关注必回关

在洛谷打开
资料、奖项与版本

资料

编号
1133796
抓取

奖项

2025 CSP-J
一等奖
2024 CSP-J
二等奖

红题444祭(2025.10.27 13:22)

红名(2026.4.5)

咕值从249暴涨到308,排名进前一千,第591名(2026.4.19)

C++
#include<bits/stdc++.h>
#include<time.h>
using namespace std;

int main(){
	cout<<"-数字炸弹!-"<<endl;
	string s,t;
	cout<<"Player 1:"<<" ";
	cin>>s;
	cout<<endl<<"Player 2:"<<" "; 
	cin>>t;
	srand((unsigned)time(NULL));
	int i=0;
	int a=rand()%100+1;
	int b,c=1,d=100;
	cout<<c<<"~"<<d<<"猜一个数:"; 
	while(b!=a){
		cin>>b;
		while(b<c||b>d){
			cout<<"请注意范围!"<<endl; 
			cout<<c<<"~"<<d<<"猜一个数:";
			cin>>b;
		}
		if(b>a){
			cout<<c<<"~"<<b-1<<"猜一个数:"; 
			d=b-1;
		}else if(b<a){
			cout<<b+1<<"~"<<d<<"猜一个数:"; 
			c=b+1;
		}
			i++;
	}
	if(i%2==1){
		cout<<s<<"输了!!!"; 
	}else{
		cout<<t<<"输了!!!"; 
	}
	return 0;
}
C++
#include<bits/stdc++.h>
#include<time.h>
using namespace std;
string s[100];
int o;
int main(){
	cout<<"-数字炸弹!-"<<endl;
	cout<<"玩家人数(限100人):"<<" ";
	cin>>o;
	for(int i=1;i<=o;i++){
		cout<<"Player"<<i<<": "; 
		cin>>s[i];
	}
	srand((unsigned)time(NULL));
	int i=0;
	int a=rand()%100+1;
	int b,c=1,d=100;
	cout<<c<<"~"<<d<<"猜一个数:"; 
	while(b!=a){
		cin>>b;
		while(b<c||b>d){
			cout<<"请注意范围!"<<endl; 
			cout<<c<<"~"<<d<<"猜一个数:";
			cin>>b;
		}
		if(b>a){
			cout<<c<<"~"<<b-1<<"猜一个数:"; 
			d=b-1;
		}else if(b<a){
			cout<<b+1<<"~"<<d<<"猜一个数:"; 
			c=b+1;
		}
			i++;
	}
	if(i%o==0){
		cout<<s[o];
	}else{
		cout<<s[i%o];
	}
	cout<<"输了!!!"<<endl;
  	for(int i=1;i<=o-1;i++){
  		if(i==o-1){
  			cout<<"嘲笑!";
  			break;
		}
    	cout<<"嘲笑!"<<endl;
  	}
	return 0;
}
C++
#include<bits/stdc++.h>
#include<time.h>
#include<Windows.h>
using namespace std;
string s[200],t[200];
int P,R,cnt,n,m[5],S;
int main(){
	system("title 数字炸弹");
	system("color 0A");
    system("date /T");
    system("TIME /T");
	cout<<"-数字炸弹!-"<<endl;
	cout << "请选择游戏模式:" << endl;
    cout << "1. 简单模式(数字范围1 - 10)" << endl;
    cout << "2. 普通模式(数字范围1 - 100)" << endl;
    cout << "3. 困难模式(数字范围1 - 1000)" << endl;
    cout << "4. 自定义模式(自行设定数字范围)" << endl;
    cout << "5. 1v1模式(自行设定数字范围)" << endl;
    int mo,x=1,y;
    cin>>mo;
    if(mo==1) y=10;
    else if(mo==2) y=100;
    else if(mo==3) y=1000;
    else if(mo==4){
        cout<<"请输入数字范围下限:";
        cin>>x;
        cout<<"请输入数字范围上限:";
        cin>>y;
    }else if(mo==5){
    	cout<<"请输入数字范围下限:";
        cin>>x;
        cout<<"请输入数字范围上限:";
        cin>>y;
        cout<<"请输入回合数:";
        cin>>n; 
        for(int i=1;i<=2;i++){
			cout<<"Player"<<i<<": "; 
			cin>>s[i];
		}
		for(int i=1;i<=n;i++){
			P=2,R=0;
			cnt=P+R;
			srand((unsigned)time(NULL));
			int k=P+R;
			while(k>1){
				int b,c=x,d=y;
				int a=rand()%(d-c+1)+c,i=0;
				cout<<s[1]<<","<<"请在"<<c<<"~"<<d<<"猜一个数:"; 
				while(b!=a){
					i++;
					if(i%(P+R)>P||(i%(P+R)==0&&R>0)){
						b=0;
						b=rand()%(d-c+1)+c;				
						Sleep(1000);
						cout<<b; 
						if(i%(P+R)!=0){
							cout<<"("<<s[i%(P+R)]<<")"<<endl;
						}else{
							cout<<"("<<s[P+R]<<")"<<endl;
						}
					}else{
						cin>>b;
						while(b<c||b>d){
							cout<<"请注意范围!"<<endl; 
							if(i%(P+R)==0){
								cout<<s[(P+R)];
							}else{
								cout<<s[i%(P+R)];
							}
							cout<<",请再在"<<c<<"~"<<d<<"猜一个数:";
							cin>>b;
						}
					}
					if(b>a){
						if((i+1)%(P+R)==0){
							cout<<s[(P+R)];
						}else{
							cout<<s[(i+1)%(P+R)];
						}
						cout<<",请在"<<c<<"~"<<b-1<<"猜一个数:"; 
						d=b-1;
					}else if(b<a){
						if((i+1)%(P+R)==0){
							cout<<s[(P+R)];
						}else{
							cout<<s[(i+1)%(P+R)];
						}
						cout<<",请在"<<b+1<<"~"<<d<<"猜一个数:"; 
						c=b+1;
					}
				}
				if(i%(P+R)==0){
					cout<<s[(P+R)];
				}else{
					cout<<s[i%(P+R)];
				}
				cout<<"被淘汰!!!"<<endl;
				for(int j=1;j<k;j++){
			    	cout<<"人机吧!!!"<<endl;
				}
				k--;
			}
			Sleep(2000);
			system("cls");
			cout<<s[1]<<"获胜!!!"<<endl;
			Sleep(2000);
		}
	}
	else{
        cout<<"无效的模式选择,默认进入普通模式"<<endl;
    }
	if(mo!=5){
		cout<<"玩家人数(限100人):"<<" ";
		cin>>P;
		for(int i=1;i<=P;i++){
			cout<<"Player"<<i<<": "; 
			cin>>s[i];
		}
		cout<<"你想要的人机数(限100人):"<<" ";
		cin>>R;
		for(int i=P+1;i<=R+P;i++){
			cout<<"Robot"<<i-P<<": "; 
			cin>>s[i];
		}
		cnt=P+R;
		srand((unsigned)time(NULL));
		int k=P+R;
		while(k>1){
			int b,c=x,d=y;
			int a=rand()%(d-c+1)+c,i=0;
			cout<<s[1]<<","<<"请在"<<c<<"~"<<d<<"猜一个数:"; 
			while(b!=a){
				i++;
				if(i%(P+R)>P||(i%(P+R)==0&&R>0)){
					b=0;
					b=rand()%(d-c+1)+c;				
					Sleep(1000);
					cout<<b; 
					if(i%(P+R)!=0){
						cout<<"("<<s[i%(P+R)]<<")"<<endl;
					}else{
						cout<<"("<<s[P+R]<<")"<<endl;
					}
				}else{
					cin>>b;
					while(b<c||b>d){
						cout<<"请注意范围!"<<endl; 
						if(i%(P+R)==0){
							cout<<s[(P+R)];
						}else{
							cout<<s[i%(P+R)];
						}
						cout<<",请再在"<<c<<"~"<<d<<"猜一个数:";
						cin>>b;
					}
				}
				if(b>a){
					if((i+1)%(P+R)==0){
						cout<<s[(P+R)];
					}else{
						cout<<s[(i+1)%(P+R)];
					}
					cout<<",请在"<<c<<"~"<<b-1<<"猜一个数:"; 
					d=b-1;
				}else if(b<a){
					if((i+1)%(P+R)==0){
						cout<<s[(P+R)];
					}else{
						cout<<s[(i+1)%(P+R)];
					}
					cout<<",请在"<<b+1<<"~"<<d<<"猜一个数:"; 
					c=b+1;
				}
			}
			int o;
			if(i%(P+R)==0){
				cout<<s[(P+R)];
				o=P+R;
				if(R==0){
					P--;
				}else{
					R--;
				}
			}else{
				cout<<s[i%(P+R)];
				o=i%(P+R);
				if(i%(P+R)<=P){
					P--;
				}else{
					R--;
				}
			}
			cout<<"被淘汰!!!"<<endl;
			for(int j=1;j<k;j++){
		    	cout<<"人机吧!!!"<<endl;
			}
			t[k]=s[o];
			for(int j=o+1;j<=k;j++){
				s[j-1]=s[j];
			}
			cout<<"剩余玩家:";
			for(int j=1;j<k;j++){
				cout<<s[j]<<" ";
			}
			cout<<endl;
			k--;
		}
		cout<<s[1]<<"获胜!!!"<<endl;
		Sleep(2000);
		system("cls");
		for(int i=1;i<=4;i++){
			cout<<"榜单生成中";
			for(int j=1;j<=i;j++){
				cout<<".";
			} 
			Sleep(1000);
			system("cls");
		}
		system("color 0E");
		cout<<"榜单:"<<endl;
		cout<<"No.1"<<":"<<s[1]<<endl;
		for(int i=2;i<=cnt;i++){
			cout<<"No."<<i<<":"<<t[i]<<endl;
		} 
		cout<<"泰裤辣!!!!!"; 
	}
	return 0;
}

王腚鱼,注重新鲜、精致、丰富,肉质紧实,味道鲜美,可以做成刺身、爆炒、清蒸、红烧……但数量稀少,目前全世界仅此一只。他出没时通常伴随着鱼叫声,常常被别人摸,这种行为被称为摸鱼。 @itape1

共 4 篇
  1. 题解

    题解:P17347 [ECNA 2025] Fractional Sequence

    该题解的核心思路是:通过累加自然数序列找到最大的整数i,使得前i-1个块的总和小于n,而第i个块的总和超过n。具体步骤如下: 确定整数部分:用sum变量累加1+2+...+i,当sum首次超过n时,停止循环。此时i-1即为S(n)的整数部分。 构造最简分数:分子为n - sum - 1(即第i个块中超出n的部分),分母为i。 化简分数:通过计算分子分母的最大公约数(gcd),将分数约分为最简形式。若分子为0则直接返回0。 代码实现中需要注意: __gcd是C++标准库外的函数,实际使用需包含 头文件或使用std::gcd 循环上限89444可能是根据题目特定条件预计算的值 特殊情况n=1直接输出1,符合题意要求

  2. 题解

    题解:P16240 【MX-X27-T1】错

    题目大意 僵尸只能隔着一个植物吃另一个植物,吃掉该植物后会传送到被吃掉的植物的位置上,求最少剩下的植物。 题目详解 这题的答案只能是 1 或 2,要么两边都有植物,要么只有一边有植物,否则就还能吃。 那么如何判断答案是 1 还是 2 呢?当僵尸一边的植物数量为 3 的倍数时,植物…

  3. 题解

    题解:P16284 [蓝桥杯 2026 省 Python A 组] 音乐节拍器

    题目大意 有 N 种乐器,每个乐器都有一个节拍周期,求在前 T 秒内,有多少个时刻是 K 种不同的乐器同时发声。 题目详解 若当前时刻的秒数可以被一个乐器的节拍周期整除,那么这个乐器在这个时刻就会发声。我们可以进行模拟,模拟每一秒内有多少种乐器发声,如果刚好等于 K,就将答案加一…

  4. 题解

    题解:P5733 【深基6.例1】自动修正

    题目大意 输入一个字符串,将这个字符串里的所有小写字母转换成大写字母。 思路 判断每一个字符是不是小写字母,如果是就把它变成大写字母。 AC code cpp #include<bits/stdc++.h> using namespace std; int main(){ str…