Strange Class

Strange Class

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 675 Accepted Submission(s): 367


Problem Description
In Vivid’s school, there is a strange class(SC). In SC, the students’ names are very strange. They are in the same format: anbncn(a,b,c must not be the same with each other). For example studens whose names are“abc”,”ddppqq” are in SC, however studens whose names are “aaa”,“ab”,”ddppqqq” are not in SC.
Vivid makes friends with so many students, he wants to know who are in SC.

Input
There are multiple test cases (about 10), each case will give a string S which is the name of Vivid’s friend in a single line.
Please process to the end of file.

[Technical Specification]

1|S|10.

|S| indicates the length of S.

S only contains lowercase letter.

Output
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.

Sample Input
abc bc

Sample Output
YES NO
#include<iostream>
using namespace std;
struct pt{
	char a;
	int t;
}m[30];
int main()
{
	string s;
	while(cin>>s)
	{
		int str = s.size() ;
		if(str%3 != 0){
			cout<<"NO"<<endl;
			continue;
		}
		int count = 1;
		m[0].a = s[0];
		m[0].t = 1;
		int j = 0;
		for(int i = 1; i< str; i ++){
			if(s[i] != s[i-1]){
				count++;
				m[++j].a  = s[i];
				m[j].t = 1;
			}
			else{
				m[j].t ++;
			}
		}
		if(count != 3)
		{
			cout<<"NO"<<endl;
		}
		else{
			if(m[0].t == m[1].t && m[1].t ==m[2].t )
			  cout<<"YES"<<endl;
	         else
	         cout<<"NO"<<endl;
		}
		//cout<<m[0].a <<" "<<m[1].a <<" "<<m[2].a <<endl;
		//cout<<m[0].t <<" "<<m[1].t <<" "<<m[2].t <<endl;
		
	}
}

1Y。。。
MATLAB主动噪声和振动控制算法——对较大的次级路径变化具有鲁棒性内容概要:本文主要介绍了一种在MATLAB环境下实现的主动噪声和振动控制算法,该算法针对较大的次级路径变化具有较强的鲁棒性。文中详细阐述了算法的设计原理与实现方法,重点解决了传统控制系统中因次级路径动态变化导致性能下降的问题。通过引入自适应机制和鲁棒控制策略,提升了系统在复杂环境下的稳定性和控制精度,适用于需要高精度噪声与振动抑制的实际工程场景。此外,文档还列举了多个MATLAB仿真实例及相关科研技术服务内容,涵盖信号处理、智能优化、机器学习等多个交叉领域。; 适合人群:具备一定MATLAB编程基础和控制系统理论知识的科研人员及工程技术人员,尤其适合从事噪声与振动控制、信号处理、自动化等相关领域的研究生和工程师。; 使用场景及目标:①应用于汽车、航空航天、精密仪器等对噪声和振动敏感的工业领域;②用于提升现有主动控制系统对参数变化的适应能力;③为相关科研项目提供算法验证与仿真平台支持; 阅读建议:建议读者结合提供的MATLAB代码进行仿真实验,深入理解算法在不同次级路径条件下的响应特性,并可通过调整控制参数进一步探究其鲁棒性边界。同时可参考文档中列出的相关技术案例拓展应用场景。
### 创建静态迷宫游戏的HTML代码示例 下面是一个简单的静态迷宫游戏的 HTML 和 JavaScript 实现。此实现允许用户通过点击按钮来导航迷宫。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Static Maze Game</title> <style> .maze { display: grid; grid-template-columns: repeat(5, 50px); grid-gap: 2px; } .cell { width: 50px; height: 50px; background-color: gray; } .player { background-color: blue !important; } .wall { background-color: black; } .goal { background-color: green; } </style> </head> <body> <h1>Maze Game</h1> <div class="maze" id="maze"> <!-- 迷宫格子 --> </div> <script> const mazeData = [ [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 2], [1, 1, 1, 1, 1] ]; function createMaze() { const mazeDiv = document.getElementById('maze'); mazeData.forEach((row, y) => { row.forEach((cell, x) => { const div = document.createElement('div'); div.classList.add('cell'); if (cell === 1) { div.classList.add('wall'); } else if (cell === 2) { div.classList.add('goal'); } div.dataset.x = x; div.dataset.y = y; mazeDiv.appendChild(div); if (y === 1 && x === 1) { // 初始位置 div.classList.add('player'); playerPosition = {x, y}; } }); }); return mazeDiv.children; } let cells = createMaze(); let playerPosition; window.addEventListener('keydown', (event) => { const dx = {'ArrowRight': 1, 'ArrowLeft': -1}[event.key] || 0; const dy = {'ArrowDown': 1, 'ArrowUp': -1}[event.key] || 0; const newX = parseInt(playerPosition.x) + dx; const newY = parseInt(playerPosition.y) + dy; const targetCell = Array.from(cells).find(cell => cell.dataset.x == newX && cell.dataset.y == newY ); if (!targetCell || targetCell.classList.contains('wall&#39;)) return; const currentPlayerCell = Array.from(cells).find(cell => cell.classList.contains('player') ); currentPlayerCell.classList.remove('player'); targetCell.classList.add('player'); playerPosition = {x: newX, y: newY}; if (targetCell.classList.contains('goal&#39;)) { alert('You Win!'); } }); </script> </body> </html> ``` 上述代码定义了一个简单网格状的迷宫,其中 `1` 表示墙壁,`0` 表示可通行路径,而 `2` 是目标终点[^3]。 用户可以通过键盘方向键移动蓝色方块到达绿色的目标区域完成游戏。 --- ### 文本冒险扩展 对于文本冒险部分,可以使用纯 HTML 和 JavaScript 来构建一个基本的故事框架: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Text Adventure</title> </head> <body> <h1>Simple Text Adventure</h1> <p id="story">你站在一座古老的城堡门前。</p> <button onclick="choosePath('enter')">进入城堡</button> <button onclick="choosePath('leave')">离开这里</button> <script> function choosePath(choice) { const storyElement = document.getElementById('story'); if (choice === 'enter') { storyElement.textContent = '你进入了城堡的大厅...'; updateOptions([ ['探索大厅', 'exploreHall'], ['返回门口', 'returnToEntrance'] ]); } else if (choice === 'leave') { storyElement.textContent = '你离开了这个地方... 游戏结束!'; clearOptions(); } else if (choice === 'exploreHall') { storyElement.textContent = '你在大厅里发现了一扇锁着的门...'; updateOptions([['尝试开门', 'tryDoor']]); } else if (choice === 'returnToEntrance') { storyElement.textContent = '你回到了城堡前...'; updateOptions([['再次进入', 'enter'], ['彻底放弃', 'leave']]); } else if (choice === 'tryDoor') { storyElement.textContent = '这扇门无法打开! 需要找到钥匙...'; updateOptions([['继续寻找线索', 'searchClues']]); } else if (choice === 'searchClues') { storyElement.textContent = '经过一番努力,你找到了隐藏在地毯下的钥匙!'; updateOptions([['回到大门处', 'goBackToDoor']]); } else if (choice === 'goBackToDoor') { storyElement.textContent = '你用新获得的钥匙打开了那扇神秘之门... 获胜!'; clearOptions(); } } function updateOptions(options) { const buttonContainer = document.body.querySelector('#options'); if (!buttonContainer) { const container = document.createElement('div'); container.id = 'options'; document.body.appendChild(container); } const optionsDiv = document.getElementById('options'); optionsDiv.innerHTML = ''; options.forEach(option => { const btn = document.createElement('button'); btn.textContent = option[0]; btn.onclick = () => choosePath(option[1]); optionsDiv.appendChild(btn); }); } function clearOptions() { const optionsDiv = document.getElementById('options'); if (optionsDiv) optionsDiv.innerHTML = ''; } </script> </body> </html> ``` 在这个例子中,玩家可以选择不同的选项推进故事发展,并最终达成结局[^4]。 --- ####
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值