hdu 5455 Fang Fang 2015沈阳网络赛 模拟

超声波熔接结构设计.pdf 技术分享 立即下载

题目

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5455

题目来源:2015沈阳网络赛第二题

简要题意:可以使用f,ff以及c后面跟大于1个f的串,问构成一个串起码要几个这样的串(可以环形移位)

数据范围: ∑|S|⩽106

题解

首先有非c,f的肯定是不行的。

没有c的话很容易推出结果为 ⌈|S|/2⌉ 。

有c的话对于一个c后面的f都只需要这个c就能带掉,而f的长度小于2就是非法的。

实现

我的方法是先特判没有cf的情况和没有c的情况。

读入之后记录所有c的位置得到一个数组,判断非法即相邻两个位置距离要大于等于 2 。

而环形的情况只要在后边多加一个就行了,即第一个往后移动|S|。

代码

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
LL powmod(LL a,LL b, LL MOD) {LL res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// head
const int N = 1E6+5;
char s[N];
vector<int> pos;

int solve(int len) {
    int vlen = pos.size();
    if (vlen == 0) return (len+1)/2;
    pos.pb(len+pos[0]);
    for (int i = 0; i < vlen; i++) {
        if (pos[i] >= pos[i+1]-2) return -1;
    }
    return vlen;
}
int main()
{
    int t, cas = 1;
    scanf("%d", &t);
    while (t--) {
        pos.clear();
        scanf("%s", s);

        int len = strlen(s);
        bool res = true;
        for (int i = 0; i < len; i++) {
            if (s[i] == 'c') {
                pos.pb(i);
            } else if (s[i] != 'f') {
                res = false;
                break;
            }
        }
        printf("Case #%d: %d\n", cas++, res ? solve(len) : -1);
    }
    return 0;
}
高校院所评估创新战略联盟成员贡献度,有哪些量化的评价模型或工具?.docx 科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。 立即下载

相关推荐

WPF毛玻璃效果别再写C#代码了!纯XAML用Border+VisualBrush+BlurEffect三步搞定

本文详细介绍了如何在WPF中通过纯XAML实现毛玻璃效果,无需编写C#代码。通过VisualBrush、BlurEffect和Clip的黄金组合,开发者可以快速创建专业级的毛玻璃面板,提升UI的现代感和视觉层次。文章还提供了性能优化技巧和实战案例,帮助开发者在各种场景中高效应用这一技术。

weixin_28630185的博客 357

HDU-5455 Fang Fang(2015沈阳网赛,带坑点水题)

坑点在,输入有其他字母,还严格按行输入(空行要输出0),但是没说。

luciozhang的博客 1487

AD2S1210与DSP28335 SPI通信中的GPIO配置陷阱与解决

本文深入剖析了AD2S1210与DSP28335进行SPI通信时,因GPIO输入限定配置不当导致数据整体右移的典型问题。文章指出,错误地将MISO引脚配置为带采样周期的同步模式是根本原因,并提供了将输入选择限制正确设置为异步模式的解决方案。同时,总结了不同应用场景下GPIO输入限定的配置原则,为高速同步通信的稳定实现提供了关键指导。

weixin_29163857的博客 151

HDU 5455 Fang Fang 2015沈阳网络赛

#include #include #include using namespace std; const int maxm=1e6+10; char s[maxm]; int main() { int t; scanf("%d",&t); int k=1; while(t--) { scanf("%s",s); int le

小马的博客 375

ESP32连接OneNet云平台实现多设备联动控制完整示例

通过esp32连接onenet云平台,实现远程设备间的智能联动控制,利用MQTT协议完成数据通信,esp32连接onenet云平台后可高效稳定地上传与下发指令,提升物联网系统响应速度与自动化水平。

weixin_42360733的博客 553

51单片机自学笔记(六)数码管动态扫描与消影实战

本文详细解析了51单片机数码管动态扫描原理与视觉暂留效应,通过硬件电路分析和C语言代码实战,重点介绍了三种数码管消影技术(段选清零法、位选屏蔽法、硬件消影法),解决了显示重影问题,并提供了常见问题调试技巧与定时器中断优化方案,帮助开发者掌握稳定的多位数码管显示技术。

y9z0a1b的博客 1109

HDU 5455 Fang Fang(2015沈阳赛区网络赛)

Fang Fang Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 685 Accepted Submission(s): 285 Problem Description Fang Fang says she wants to

Sterben_Da的博客 597

SpringCloud2025+SpringBoot3.5.0动态路由503问题排查与负载均衡依赖解析

本文详细排查了SpringCloud 2025与SpringBoot 3.5.0环境下,Spring Cloud Gateway动态路由返回503错误的根本原因。核心问题在于新版网关未默认集成负载均衡器,导致无法解析lb://服务名。通过对比静态路由与动态路由,定位到需显式引入spring-cloud-starter-loadbalancer依赖,并提供了完整的解决方案与最佳实践配置。

s3t4u的博客 507

hiho 1271 舰队游戏 状压dp 贪心 模拟

题目 题目链接:http://hihocoder.com/problemset/problem/1271 题目来源:hiho的比赛。 简要题意:给定对空和对舰的飞机还有一个航母,给定计算公式,要你弄个奇怪的方案。

ned_chu的博客 915

R_柱状图(加误差线,显著性差异)

先放最终效果图 结果图 # bar_plot 2021/01/19 # 导入所需的包 library(ggplot2) library(ggthemr) library(ggsignif) library(tidyverse) library(dplyr) library(ggpubr) library(devEMF) # 导入并处理数据,需要两张表,一个是原始汇总表格,另外一些是每一...

wt141643的博客 2万+

基于TL431与光耦的电压反馈环路优化设计实战

本文深入探讨了基于TL431与光耦的电压反馈环路优化设计实战。文章从理解这对“黄金搭档”的工作原理入手,详细拆解了电压采样电阻网络、偏置电路、光耦工作点设置以及动态补偿网络的设计心法与计算步骤。重点分享了如何通过RC补偿网络调试,确保环路在各种负载下稳定可靠,并提供了关键的实战避坑指南,帮助工程师解决电源设计中常见的振荡、噪声及可靠性问题。

nginx7reverse的博客 788

hiho 1268 九宫 搜索 模拟

题目 题目链接:http://hihocoder.com/problemset/problem/1268 题目来源:hiho上的比赛 简要题意:给定3×33\times 3矩阵,一些空缺,问是否能构成唯一幻方。

ned_chu的博客 759

k3s cpu load 和 cpu 使用率很高处理

在这期间还执行过缩减 sqlite3 数据库操作,不知道是哪个操作起了作用,亦或者两个操作有影响,删除 ns 促进了数据库缩减的执行(没删除之前数据库缩减不成功,db文件大小未减小,但不确定是不是执行完 VACUUM 之后需要时间 db 文件才会减小,或者是因为删除了 ns 才导致其减小),再或者是两个操作都起了作用。kubectl get ns 发现有很多卡在删除状态的 ns。k3s 官网关于这个问题的谈论。执行如下脚本删除掉这些 ns。有人详细说过这个问题。

weixin_40548182的博客 690

hdu 5532 Almost Sorted Array 2015 长春区域赛 模拟

2015长春网络赛第二题。

ned_chu的博客 743

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Codeforces #342 D. Finals in arithmetic 模拟 构造

构造好题。

ned_chu的博客 713

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

hiho 1270 建造基地 dp 完全背包 模拟

题目 题目链接:http://hihocoder.com/problemset/problem/1270 题目来源:hiho上的比赛 简要题意:建造基地,有代价和贡献,基地升级贡献要除tt求建造的最小代价。

ned_chu的博客 687

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces edu 6. F Xors on Segments 枚举 优化技巧

题目链接:http://codeforces.com/problemset/problem/620/F 题目来源: Educational Codeforces Round 6 简要题意:求区间内的数两两配对组成区间,区间内数异或起来的最大值。

ned_chu的博客 662

UVALive 4725 Airport 贪心 二分 模拟

题目 题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17264 题目来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=105318#overview 简要题意:两个机场,每小时一些飞机到达,每小时安排一架飞机起航。

ned_chu的博客 631

Codeforces #349 div1 B. World Tour 模拟 技巧

题目 题目链接:http://codeforces.com/contest/666/problem/B 题目来源:Codeforces #349 div1

ned_chu的博客 616

Codeforces edu 6. D Professor GukiZ and Two Arrays 二分搜索 枚举

题目链接:http://codeforces.com/contest/620/problem/D 题目来源:Educational Codeforces Round 6 简要题意:对于两个数组,在两数组间最多交换两次,求两数组之和的差的绝对值最小值。

ned_chu的博客 603

UVA 11627 Slalom 二分 模拟

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=107574#problem/E 题目来源:2016.2.26群赛 简要题意:给定雪橇的垂直速度和固定的水平速度,给定一些门的左右区间和y坐标。 求能够穿过所有门的雪橇中速度最快的,不可能则特殊输

ned_chu的博客 583

hdu 5475 An easy problem 2015上海网络赛 模拟 剪枝

上海网络赛的第二题

ned_chu的博客 565

hdu 4782 Beautiful Soup 2013成都区域赛 大模拟

2013成都区域赛第五题的样子。大模拟。

ned_chu的博客 562

Uva 12657 Boxes in a Line 链表 模拟

题目 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110383#problem/B 题目来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110383#overview

ned_chu的博客 547

hihoCoder 1228 Mission Impossible 6 2015北京网络赛 大模拟

2015北京网络赛第四题

ned_chu的博客 544
上一篇: 计算机中树的优点与重要性
下一篇: hdu 5459 Jesus Is Here 2015沈阳网络赛 递推
ned_chu
博客等级 码龄12年 69粉丝 167原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值