:Parencodings

医疗器械软件测试输出内容(1) *单元测试(Unit Testing):**单元测试是软件测试的最底层,用于验证软件中最小的可测试单元——函数、方法或模块。系统测试是在集成测试之后进行的,它对整个系统进行测试,验证系统在不同部分集成在一起后是否满足需求和规格。: 集成测试是在单元测试之后进行的,它关注不同单元之间的交互和集成。对于不同安全级别的软件(IEC 62304 A类、B类、C类),在体系上要求输出的文件内容有所区别。**说明:**将集成测试和软件系统测试合并为一项单一的计划和一组活动是可接收的。 阅读详情

 

Parencodings

D1075:Parencodings

时间限制:
1000ms
内存限制:
65536kB
描述
Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways:
q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right parenthesis in S (P-sequence).
q By an integer sequence W = w1 w2...wn where for each right parenthesis, say a in S, we associate an integer which is the number of right parentheses counting from the matched left parenthesis of a up to a. (W-sequence).

Following is an example of the above encodings:
	S		(((()()())))
	P-sequence	    4 5 6666
	W-sequence	    1 1 1456

Write a program to convert P-sequence of a well-formed string to the W-sequence of the same string.
输入
The first line of the input contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case is an integer n (1 <= n <= 20), and the second line is the P-sequence of a well-formed string. It contains n positive integers, separated with blanks, representing the P-sequence.
输出
The output file consists of exactly t lines corresponding to test cases. For each test case, the output line should contain n integers describing the W-sequence of the string corresponding to its given P-sequence.
样例输入
2
6
4 5 6 6 6 6
9 
4 6 6 6 6 8 9 9 9
样例输出
1 1 1 4 5 6
1 1 2 4 5 1 1 3 9

我是按模拟的方法做的,代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a[40], b[40];
int main()
{
    int t, x, m, n, i;
    scanf("%d", &t);
    m = 0;
    while(t--){
        memset(a, -1, sizeof(a)); //赋值为-1
        scanf("%d", &n);
        for(i=0; i<n; i++){
            scanf("%d", &x);
            if(a[x]==-1){
                b[i] = 1;
                a[x] = 0;
            }
            else
            {
                m = 1;
                while(a[x]!=-1){
                    x--;
                    m++;
                }
                b[i] = m;
                a[x] = 0;
            }
        }
        for(i=0; i<n; i++){
            printf("%d ", b[i]);
        }
        printf("\n");
    }
    return 0;
}


 

 

1448•纯粹素数 纯粹素数是这样定义的:一个素数,去掉最高位,剩下的数仍为素数,再去掉剩下的数的最高位,余下的数还是素数。对于每一个数(无论质数合数)x,筛掉所有小于x最小质因子的质数乘以x的数。但我们知道,我们选择的那个质数必须小于那个合数的最小质因子。p3,因为p2>p1,所以这样是筛不到的。唯一会筛的是第一种:p1和p2*p3。c,s肯定小于刚才那个合数,说明肯定对于它已经筛过,然后a肯定小于s,因为s=b。p3,并且保证p1<p2<p3。我们知道,筛掉这个合数的机会有:p1和p2。c,并且a是最小的因子。 阅读详情

相关推荐

【超详细】磁力计数据读取--以IST8310为例

第一章讲了IST8310的特性,I2C通信,最高支持400kHz通信速率,14位或者16位自适应数据输出等特性第二章讲了内部结构第三章讲了电气特性第四章讲了如何联系他们然后数据手册就没了。。。在大疆的开发手册中找到了寄存器的手册,如下:点开I2C配置选项, 下图是配好的:观察IST8310的数据手册,发现其支持最大400kHz的I2C通信速率,也就是快速I2C模式,所以第一行I2C Speed Mode我们选Fast Mode同时不要忘记了在C板中I2C3的两个IO口分别是PA8和PC9(一般来说都是这两个

lmh_12138的博客 1万+

PAT.Advanced.P1068

------>   原题链接    题意大概是有1w个硬币,店家只要精确数额(不多收也不找零)问能否凑出给出的数额。 做法就是暴力循环 + 剪枝优化 不剪枝的话有一个点是过不去的。 1、剔除所有大于给定数量的硬币, 2、对于重复的硬币,如果第一个不行,那么排除掉后面所有的重复硬币的可能性。(见注释的核心剪枝行) #include #include #include #inclu

A.Z.L的博客 454

Ghost备份还原Win10全攻略:从老电脑迁移到新硬盘,ESP分区处理是关键

本文详细介绍了使用Ghost工具将Win10系统从旧电脑迁移到新硬盘的全过程,特别强调了ESP分区的关键处理方法。通过分步指导备份、分区准备、系统还原和引导修复,帮助用户实现无缝系统迁移,解决常见问题如启动失败和驱动兼容性。

weixin_30823001的博客 672

1068:Parencodings

栈,括号匹配 解题思路: 根据P串还原出括号串:第一个数是4,说明第一个右括号前有4个左括号;第二个数是5,说明到一个右括号后,有5-4个左括号,依次类推,还原出括号串。 用栈来匹配括号:很容易发现,中间包含多少个括号对,可以直接用左括号和右括号的下标来计算。因此,碰到左括号时,把其下标压入栈,碰到右括号时,出栈,由两个下标计算出结果。 参考:https://blog.youkuaiyun.com/xp731574722/article/details/76566171 //栈,括号匹配 #include <

weixin_49403900的博客 215

【博弈论】势博弈(potential game)、EPG以及最佳响应、Nash均衡和帕累托(pareto)最优的理解

文章目录前言一、Potential game二、Nash均衡和Pareto-optimal(帕累托最优)1.Nash 均衡2.Pareto最优三、Best response(最佳响应)四、Exact potential game(EPG)1.合作-傀儡博弈2.合作博弈3.傀儡博弈4.自激博弈5.双边对称交互博弈使用理解 前言 本文主要详细讲解potential game的概念以及Exact potential game 的定义和分类,以及这么博弈方法是如何在论文中引入并使用的,本文仅是对自己在该模块

weixin_44535200的博客 2万+

CentOS8静默安装Oracle11.2.0.1

背景 新安装oracle,用静默安装方式就不需要安装图形界面了,省时省力。 前期准备工作与图形化安装一样,如创建用户|用户组、环境变量、内核参数、创建目录等. 可参考图形化安装,链接:https://blog.youkuaiyun.com/heroicpoem/article/details/104229369 环境 平台 版本 操作系统 centOS 8 Oracle 11gR2 1.响应文件 响应文件的内容就是图形化安装时手工设置的选项内容。 解压后,database/response/db

heroicpoem的专栏 4518

Parencodings

ParencodingsTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 134    Accepted Submission(s): 89Problem DescriptionLet S = s1 s2 … s2n be a w

Rachel Zhang的专栏 2546

电表协议避坑指南:DLT645-2007与Modbus RTU的5大核心差异对比

本文深入对比了DLT645-2007与Modbus RTU两大电表通讯协议的核心差异,涵盖协议定位、数据地址、报文结构及实测性能。DLT645-2007作为电力行业标准,数据定义统一但效率受限;Modbus RTU作为通用协议,灵活高效但需依赖厂家点表。文章结合实测数据与开发经验,为不同场景下的协议选型与编程实践提供了清晰的避坑指南。

weixin_29166013的博客 106

Parencodings(简单模拟法)

链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22007#problem/A G - Parencodings Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Description

JHC23的专栏 1821

如何通过Davinci Configurator来新增一个BswM仲裁规则

详细介绍如何通过Davinci Configurator来新增一个BswM仲裁规则。

initiallizer的博客 771

AWS SQS跨账户访问失败排查指南

在使用AWS SQS(Simple Queue Service)时,跨账户访问是常见的业务场景。例如,账户A的应用程序向队列发送消息,账户B的消费者从队列拉取消息。尽管AWS官方文档明确支持此类配置,但在实际应用中,由于权限模型的复杂性,开发者和运维人员常会遇到“策略已配置但无法接收消息”的问题。通过本文的逐步排查指南,您不仅可以解决当前问题,还能深入理解AWS跨账户访问的权限模型。接收方账户的用户或角色必须同时附加IAM策略,显式授权操作目标队列。尽管策略看似允许接收方操作,实际测试中却返回空消息或。

探索云原生与智能化驱动下的安全运维新范式。关注DevSecOps、可观测性、AIOps等前沿领域,与您共赴技术前沿。 457

Parencodings--POJ 1068

1、题目类型:模拟题。 2、解题思路:(1)根据输入数据建立Arr[],0表示'(',1表示')';(2)搜索为Arr[]中为 1 的位置,并找到与之相匹配的 0 ,cnt表示对应的匹配间1的个数。 3、注意事项:flag[i]标示Arr[i]是否已完成匹配;flag[]注意及时清空。 4、实现方法: #include<iostream>using namespace st...

weixin_33950035的博客 159

Python图像处理之光斑分析

光斑是工程中经常出现的图像数据,其特点是目标明确,分布清晰。对光斑图像的分析,主要包括质心定位、目标截取以及半径拟合等。

微小冷的学习笔记 2857

Poj 1068:Parencodings

Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses bef

Valieli的博客 572

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

1044: Parencodings

<br /> 1044: ParencodingsResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s8192K613302Standard<br />Let S = s1 s2 … s2n be a well-formed string of parentheses. S can be encoded in two different ways:By an integer sequence P = p1 p2 … pn where pi is the n

kongming_acm的专栏 398

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

ACM 算法题:Parencodings

对于正常的括号对序列,也就是左括号与右括号的数目是相等的,并且成对。例如(((()()()))),总共有n个括号。 通过两种形式对括号对编码: P序列: P = p1 p2 … pn Pi是第i个右括号之前左括号的数目。 W序列: W = w1 w2 … wn Wi是第i个右括号与之匹配及其包含的左括号的数目。 要求:写一个算法,将括号对的P序列转换成W序列。

vshadow的专栏 924

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

POJ 刷题系列:1068. Parencodings

POJ 刷题系列:1068. Parencodings传送门:1068. Parencodings题意: 给出一组P-Sequence,每个数代表当前右括号之前的所有左括号数,求W-Sequence,表示当前右括号与它对应的左括号之间的左括号数。还是看例子吧: 思路: 抓住两点,对应于P-Sequence,对于每个右括号i,插入的左括号数为p[i] - p[i - 1]。对于W-Seq

Demon-初来驾到 504

POJ1068《Parencodings》方法:模拟

题目大意:将一种括号表现形式转变为另一种,通过变为中间字符串000010101111的形式转化,easy。 #include #include #include using namespace std; int main() { //freopen("temp.txt", "r", stdin); int t, n; int p[21] = {0}; //P串,p[0]=0很重

相门码农的专栏 457

ZOJ--1016:Parencodings

Parencodings Time Limit: 2 Seconds      Memory Limit: 65536 KB Let S = s1 s2 ... s2n be a well-formed string of parentheses. S can be encoded in two different ways: By an integer sequenc

yf224的博客 451

POJ 1068:Parencodings

Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22849   Accepted: 13394 Description Let S = s1 s2...s2n be a well-formed string of parentheses

532

POJ:1086-Parencodings

ParencodingsTime Limit: 1000MS Memory Limit: 10000KDescriptionLet S = s1 s2…s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1

二营长的意大利炮友 291

POJ 1068:Parencodings(模拟)

Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right pare

并非所有流浪者都迷失了自我 489

POJ模拟——Parencodings

Parencodings Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Description Let S = s1 s2...s2n be a

空白页 633

Parencodings 分类: POJ 20...

Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22757 Accepted: 13337 Description Let S = s1 s2...s2n be a well-formed string of parentheses...

weixin_30275415的博客 69

Parencodings(poj模拟法)

Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses bef

jinzk123的博客 751

POJ 1068 Parencodings 模拟 难度:0

http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; int ind[45]; bool used[45]; int r[21]; int l[21]; int len,n,llen; int w[21]; int main(){...

weixin_30814329的博客 98
下一篇: 最短回文串
GOFORACM
博客等级 码龄15年 0粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值