当前位置: 首页 > news >正文

万互网站建站网站建设怎么提需求

万互网站建站,网站建设怎么提需求,网站建设 备案什么意思,中国建设布网站时隔这么久 重温Div.2的难度的比赛还是变得有点棘手了 还是得一直练保持手感💪 比赛链接:点击此处进入 A题: You are given a binary string∗^{\text{∗}}∗ sss of length nnn and you are allowed to perform the following operation a…

时隔这么久 重温Div.2的难度的比赛还是变得有点棘手了 还是得一直练保持手感💪

比赛链接:点击此处进入

A题:

You are given a binary string∗^{\text{∗}} sss of length nnn and you are allowed to perform the following operation any number of times (including zero):

  • Choose 333 indices KaTeX parse error: Expected 'EOF', got '&' at position 9: 1 \le i &̲lt; j < k \l… and right shift or left shift the values on sis_isi, sjs_jsj, sks_ksk cyclically.

For the binary string 110110, if we choose i=1i=1i=1, j=2j=2j=2, k=3k=3k=3 and perform a right shift cyclically, the string becomes 011110; if we choose i=4i=4i=4, j=5j=5j=5, k=6k=6k=6 and perform a left shift cyclically, the string becomes 110101.

Determine the minimum number of operations required to sort the given binary string.

∗^{\text{∗}}A binary string is a string that consists only of the characters 0 and 1.
Input

Each test contains multiple test cases. The first line contains the number of test cases ttt (1≤t≤1001 \le t \le 1001t100). The description of the test cases follows.

The first line of each test case contains a single integer nnn (3≤n≤1003 \le n \le 1003n100) — the length of the string.

The second line contains a binary string sss of length nnn.
Output

For each test case, output a single integer — the minimum number of operations required to sort the given binary string.
Note

For the first test case, the given string is already sorted. So, no operations are needed.

For the second test case, we can choose i=1i = 1i=1, j=2j = 2j=2, k=4k = 4k=4 and perform a right shift cyclically. The string becomes equal to 0011, which is sorted.

由于我们可以选择的三个数是可以不连续的,所以我们每次都可以选择不在应有位置上的元素进行操作,那么这个时候我们就要考虑对原字符串进行排序操作了,排序之后才能通过与元字符串进行对比找出不在应在位置的元素的个数。
然后就是考虑怎么对这些元素进行操作呢?我们可以手写几个例子就能看出规律,因为循环移位既可以向左又可以向右,所以这个时候任意三个元素都可以在一次操作内变得有序,那么到这里可能就会想,答案是不是让这些元素的个数除以3呢?
其实这里也有可以细节:我们不难发现,不在该在位置的元素的个数一定是偶数个,然后我们还能够发现,实质上,我们的每次操作,对其中的三个元素进行操作的时候,其实只有两个位置上的元素互换位置了,总会有一个元素的位置保持不变,所以每一次操作实质上只有两个元素在起作用,所以最终的答案就是cnt / 2!

// Problem: A. Shift Sort
// Contest: Codeforces - Codeforces Round 1049 (Div. 2)
// URL: https://codeforces.com/contest/2140/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
#define fi first
#define se second
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define lbt(x) ((x) & (-x)) const int INF = 0x3f3f3f3f;
const int inf = 1e18; void solve()
{int n;cin>>n;string s;cin>>s;string t = s;sort(t.begin(),t.end());int cnt = 0;// cout<<s<<endl<<t<<endl;for(int i=0;i<n;i++)if(s[i] != t[i]) cnt ++;// cout<<cnt<<endl;cout<<cnt / 2 <<endl;
//	cout<<fixed<<setprecision(x)<< ; 
}signed main()// Don't forget pre_handle!
{IOSint T=1;cin>>T;while(T--) solve(); return 0;
} 

B题

Alice and Bob are playing a game in which Alice has given Bob a positive integer KaTeX parse error: Expected 'EOF', got '&' at position 2: x&̲lt;10^8.

To win the game, Bob has to find another positive integer KaTeX parse error: Expected 'EOF', got '&' at position 2: y&̲lt;10^9 such that x#⁡yx \operatorname{\#} yx#y is divisible by x+yx + yx+y.

Here x#⁡yx\operatorname{\#}yx#y denotes the integer formed by concatenating the integers xxx and yyy in that order. For example, if x=835x = 835x=835, y=47y = 47y=47, then x#⁡y=83547x \operatorname{\#} y = 83\,547x#y=83547.

However, since Bob is dumb, he is unable to find such an integer. Please help him.

It can be shown that such an integer always exists.
Input

Each test contains multiple test cases. The first line contains the number of test cases ttt (1≤t≤1041 \le t \le 10^41t104). The description of the test cases follows.

The only line of each test case contains a single integer xxx (KaTeX parse error: Expected 'EOF', got '&' at position 9: 1 \le x &̲lt; 10^8) — the integer that Alice has given to Bob.
Output

For each test case, print a single integer yyy (KaTeX parse error: Expected 'EOF', got '&' at position 9: 1 \le y &̲lt; 10^9) so that Bob can win the game.

If there are multiple answers, print any one of them.
Note

For the first test case, x=8x = 8x=8, we can choose y=1y = 1y=1, and we have x#⁡y=81x \operatorname{\#} y = 81x#y=81, which is divisible by x+y=9x + y = 9x+y=9.

For the second test case, x=42x = 42x=42, we can choose y=12y = 12y=12, and we have x#⁡y=4212x \operatorname{\#} y = 4212x#y=4212, which is divisible by x+y=54x + y = 54x+y=54.

这道题是和数学相关的一道题,这里给大家分享一个小技巧:
我们对于这类题目可以用数学表达式来将过程模拟出来,就拿这道题来说:

  • 首先题目中所给定的元素x,我们在与y进行拼接操作之后的数学表达式为:x*10^len+y
  • 其中len表示x的位数
  • 然后,我们要想使之能够被x + y整除,那么这时候的数学表达式就是:(x*10^len+y) / (x+y)
  • y的取值肯定不是随便乱取的,一定和x有着某种倍数关系才能整除
  • 那我们就开始想,到底是多少倍才合适?
  • 看到10^len,我们就能想到对3作除法,因为不管是10的几次方,对3作除法都是余1!
  • 因为x被的10的k次方对3倍的x作除法少两个x才能整除,所以y就直接取的2倍的x即可!
    代码:
// Problem: B. Another Divisibility Problem
// Contest: Codeforces - Codeforces Round 1049 (Div. 2)
// URL: https://codeforces.com/contest/2140/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
#define fi first
#define se second
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define lbt(x) ((x) & (-x)) const int INF = 0x3f3f3f3f;
const int inf = 1e18; void solve()
{int x;cin>>x;cout<<2LL * x<<endl;
//	cout<<fixed<<setprecision(x)<< ; 
}signed main()// Don't forget pre_handle!
{IOSint T=1;cin>>T;while(T--) solve(); return 0;
} 
http://www.dtcms.com/a/528447.html

相关文章:

  • 国产 做 视频网站陕西建筑培训网
  • [人工智能-大模型-69]:模型层技术 - 计算机处理问题的几大分支:数值型性问题、非数值型问题?
  • 0. Qt 安装及源码及报错
  • jQuery 事件方法详解
  • 基于Python大数据的热门游戏推荐系统
  • 网站如何做关健词收录网站应该如何推广
  • 网站应该如何进行优化微信企业网站 源码下载
  • LlamaFactory的docker-compose安装
  • RK3568笔记102:基于LVGL8的车载娱乐小平板设计
  • 技术随笔:Node.js ESM 中巧用 `-r dotenv/config` 解决环境变量异步加载问题
  • 网站做端口是什么有没有可以免费做试卷的网站_最好可以学会...
  • 游戏人物设计 简单思路 那任务简单说是显示的 完成任务是每个条件脚本自己判断 完成后发给任务脚本信息
  • 利用消息队列(MQ)设计:解耦与异步削峰的艺术
  • 自由学习记录(111)
  • ESP32使用笔记(基于ESP-IDF):小智AI的ESP32项目架构与启动流程全面解析
  • 网站建设 软文网站创作思路
  • 未来之窗昭和仙君(三十七)抽奖随机算法修仙体——东方仙盟筑基期
  • HCIP---作业
  • 海天建设集团公司网站vi应用设计
  • Mybatis10-xml文件与mapper文件的目录位置说明
  • 安全的网站网站开发要
  • 面向模块的综合技术之综合策略优化(六)
  • Mem0:构建具有可扩展长期记忆的生产级AI代理 - 论文学习总结1
  • 【三相异步电动机判断好坏】
  • 整体设计 全面梳理复盘 之6 整体设计表格体系与执行逻辑迭代
  • SpringBoot集成Elasticsearch | Spring官方场景启动器(Spring Data Elasticsearch)方式
  • 【计挑赛】程序设计类真题(C++)
  • HTML HTML5基础(1)
  • 2025年9月电子学会全国青少年软件编程等级考试(Python五级)真题及答案
  • (论文速读)Anyattack: 面向视觉语言模型的大规模自监督对抗性攻击