杭电acm 1708 字符串相加再计数

SAE J1708协议 SAE J1708协议 1.协议简介 1708是SAE(Society of Automotive Engineers:美国机动车工程师学会)专门针对重型车辆(卡车和客车)起草文件中J标准规范之一,该协议旨在推广微控制器模块之间的通信标准规范。SAE J1708协议仅详细描述了OSI(Open System Interconnection:开放式系统互联)七层模型中的物理层和数据链路层。所以在进行通信时,常常需要与描述应用层的SAE J1587协议一起使用。 图1-OSI模型 ... 阅读详情
#include <stdio.h>  
#include <string.h>  
int main()  
{  
    int n, k, f[51][27], i, j;  
    char str1[31], str2[31];  
    scanf("%d", &n);  
    while (n--)  
    {  
        scanf("%s%s%d", str1, str2, &k);  
        memset(f, 0, sizeof(f));  
        for(i = 0; str1[i] != NULL; i++)  
            f[0][str1[i] - 'a']++;  
        for(i = 0; str2[i] != NULL; i++)  
            f[1][str2[i] - 'a']++;  
        for(i = 2; i <= k; i++)  
            for (j = 0; j < 26; j++)  
            {  
                f[i][j] = f[i-1][j] + f[i-2][j];  
            }  
        for(i = 0; i < 26; i++)  
            printf("%c:%d\n", i + 'a', f[k][i]);  
        printf("\n");  
    }  
    return 0;  
}  

该题思路:用二维数组,一个用于递推,一个用于统计每个字母数。同时灵活运用字符ASCII码值。

【ACM】杭电OJ 1002 题目链接:杭电OJ 1002 表面上看是a+b,很简单,其实是大数的相加,所以要考虑的因素有很多;(瞬间觉得要是能用Python多好,哈哈哈) 还有!!! 要特别注意格式的输出!!!真的害死人!!!摸不清输出格式到底是啥,只能多尝试几下!!! 思路: 我是先找处两个字符串中长度较大的那个,(但是也有特殊情况,例如“5”+“7”,需要进一位,所以,在前面需要预留一个空格,如果最后是“0... 阅读详情

相关推荐

杭电ACM离线题库(1000-4955)

杭电ACM离线题库(1000-4955)

杭电 HDU ACM 1708 Fibonacci String

Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4102    Accepted Submission(s): 1396 Problem Description After lit

舒哥的blog 959

光伏发电预测(LSTM、CNN_LSTM和XGBoost回归模型,Python代码)

一旦结果与预测差距较大,可能存在光伏系统的问题,需要找出原因,然后采取适当措施来修复光伏系统并做出更好的决策。例如,根据准确的预测,光伏系统运营商可以平衡电力消耗,并将多余的电力储备用于紧急情况。然而,光伏系统的发电量估算是一个挑战,因为光伏系统的发电量受到天气条件的极大影响。整个项目文件夹(第一个文件夹为xgboost模型相关的包文件,xg.py是xgboost模型英文注释版本,xg_chinese.py是xgboost模型中文注释版本)表示空气的温度,通常以摄氏度(°C)或华氏度(°F)为单位。

2301_79699110的博客 3032

CF1043DIV3 D From 1 to Infinity

摘要: 题目要求计算由连续整数拼接而成的无限序列前k位数字的各位数字之和。通过将数字按长度分组,确定k位所在的整数n及其位置pos。计算1到n-1的数字和时,分解每一位的贡献:前i位固定时的数字和与后面位均匀分布的贡献。最后加上n前pos位的数字和。该算法高效处理超大k值(如1e15),通过数学推导避免了直接遍历,确保时间复杂度与数字位数相关。样例验证了方法的正确性。

wuyan_angel的博客 570

ESP-IDF的安装及其在VScode中编译环境的搭建

从安装目录的\Espressif\frameworks\esp-idf-v5.3.2\examples路径中拷贝一个工程到项目中,比如拷贝\get-started下的hello_world文件夹。安装时可能会遇到如下问题,提示:"e:\ssc\software\ESP-IDF\v5.3.2\Espressif\tools\idf-python\3.11.2\python.exe -m pip" is not valid. (ERROR_INVALID_PIP)接着等待安装完成即可,其他步骤同方式1。

Freddy_Ssc的博客 4371

从稳压管到LDO芯片:一张图看懂线性电源的‘内卷’进化史

本文追溯了从稳压管到LDO芯片的线性电源技术进化历程,详细解析了各阶段的技术突破与局限。重点探讨了现代LDO在超低功耗、高精度控制等方面的创新,并提供了实战选型的黄金法则,帮助工程师在电子设备小型化与低功耗化趋势中做出最优选择。

weixin_42525551的博客 206

无限计数逻辑

无限计数板说明 说明 与以往切割字符串完成无限计数不同,我是利用纯数学算法完成的无限计数,效率相对较高,非常实用,但逻辑性较强,希望大家都能够理解,代码如下: //声明变量记录分数 var count = 0; //没多一位创建一个img var creatImg = 1; //新创建的img var img2; var img1=[]; //得分 count++; //判断分数有多少位 wh...

xiao_haiyang的博客 513

CXL Virtual Hierarchy (VH) Enumeration理解

在 CXL 3.0 协议中,CXL Virtual Hierarchy (VH) Enumeration 是一种针对 CXL 虚拟层级(Virtual Hierarchy) 设计的设备枚举机制,它允许软件将物理连接的 CXL 设备抽象为多个逻辑层级(虚拟层级),从而实现更灵活的资源管理和拓扑扩展。与传统的 PCIe 枚举相比,CXL VH 枚举在协议特性、拓扑抽象和资源分配机制上有显著差异。本质:VH 是一个逻辑上的设备层级结构,可能与物理连接拓扑不同。

Summer的博客 1003

2024杭电ACM-个人PK赛(1) B 子集整除

首先,对于之前已经产生的答案ans,ans*=2,对于之前所有的序列都可以选择加入该元素也可以选择不加入该元素。为了计算这种贡献,我们需要维护一个h数组,h[j]即(序列数字之和)%k==j的序列的数量。对于该元素加入之前序列的情况,我们要继续讨论该元素的贡献。余项 lf=a[i]-(a[i]/k)*k产生的贡献。第二类:该元素单独产生的贡献(即序列{a[i]})第一类:该元素加入之前的序列产生的贡献。a[i]/k 产生的贡献。

liboshijjj的博客 982

Type-C转DP1.4转C双向互传转接线方案

Type-C转DP双向互转方案的核心在于利用Type-C接口中的Alt Mode(交替模式)功能。通过利用Type-C接口的Alt Mode功能,该方案实现了Type-C接口与DP接口之间的双向互传,极大地丰富了用户的视觉体验。在选择Type-C转DP双向互转方案时,用户需要关注兼容性、性能需求、线缆长度和品牌等因素,以确保获得最佳的传输质量和使用体验。因此,Type-C转DP双向互转方案应运而生,旨在实现Type-C接口与DP接口之间的无缝连接,满足用户对高效能和高清晰度视频传输的需求。

m0_70875024的博客 4977

【测开求职】面试题:操作系统 吐血整理

本篇文章是笔者为准备研究生复试和校招而写,因此主要针对问答,注重理解,而不在于细节计算。涵盖考研范围内的所有知识内容,读者可以先查看上面的链接走一遍操作系统的整体框架结构。其中,重点难点以及易混淆的知识点,笔者用其他文章进行了详述,在知识点处贴好了链接,有需要的可以查阅。另外操作系统在校招中有非常明显的重点,一般情况下只会考察进程管理,内存管理,和设备管理,且这三者考察频率依次递减,文件管理基本不会考察。

vector的博客 7909

杭电acm1708

http://acm.hdu.edu.cn/showproblem.php?pid=1708 题意就是把两个串当做初始串,像斐波那契数列那样连接起来,然后计算第N个串各个字母出现的次数,思路是运用斐波那契数列思想,计算得,当N为0时,是第一个串,1时就是第二个串,三个以上的,就是串1对应f[n-2],串2对应f[n-1],然后逐个叠加 #include<stdio.h&...

anccx84886的专栏 135

图神经网络学习笔记-点云数据处理(专题七)

本教程解释了如何利用图神经网络(Graph Neural Networks,GNNs)来处理和训练点云数据。尽管点云默认情况下不具有图结构,但我们可以利用 PyG 的转换工具,将其转化为适合 PyG 所提供的全套 GNN 模型的形式。关键思想是从点云数据中创建一个,通过 GNN 的消息传递机制,从中学习有意义的局部几何结构。这些点的表示可以被用于例如点云分类或分割等任务。

351

HDU 1708 Fibonacci String(字符串的处理)

题目链接: AC代码:

风尘_浪子 906

Vue+OpenLayers7入门到实战目录,OpenLayers7中文文档,OpenLayers7中文手册,OpenLayers7中文教程,OpenLayers7文档pdf

本篇作为《Vue+OpenLayers7入门到实战》所有文章的二合一汇总目录,方便查找。本专栏源码是由OpenLayers7.x版本结合Vue框架编写。本专栏从Vue搭建脚手架到如何引入OpenLayers7依赖的每一步详细新手教程,再到通过各种入门案例和综合性的实战案例,带领大家快速上手Vue+OpenLayers7开发。

GIS技术方向,GIS地图技术分享(GIS入门、Openlayers教程、Leaflet教程),做最好的GIS地图开发教程。关注博主公众号:eguid 3973

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

杭电OJ刷题指南(ACM)

1.首先,打开百度,输入“杭电OJ”进行搜索 2.然后进入杭电OJ官网,进行注册 3.输入注册信息 4.接下来进入详细注册界面,将信息填写完整后点击Submit 5.接下来即可登录帐号,填写用户名和密码后 点击Sign in 6.接下来,进入刷题界面 7.英文题自行翻译,从11页开始有中文题,无论中英完成后都计入刷题数 8.做题时一定要仔细看题,积极尝试 9. 选择答题语言为C语言...

qq_38769551的博客 9万+

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

HDU 1708 Fibonacci String(字符串模拟)

题目地址:点击打开链接 思路:任意一个字符串都是由最初的第零个和第一个构成的,只要记录含有的第零个和第一个字符串的个数即可 AC代码: #include #include #include #include #include #include #include #include #include #include #include typedef long long

Java识堂,一个有干货的微信公众号 1020

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 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")

杭电ACM2018题

#include&lt;stdio.h&gt; int main() { int n,i,a[55]; while(scanf("%d",&amp;n)!=EOF) { if(n==0) break; a[1]=1; a[2]=2; a[3]=3; a[4]=4; ...

qq_43104182的博客 2410

杭电ACM 2017:字符串统计

原创作品 转载请注明出处http://blog.youkuaiyun.com/always2015/article/details/45477533很简单的一道题目,我的AC代码如下:#include <iostream> #include<string> using namespace std;int main() { int n,digital_num=0,length; string in

去实验室,奔跑吧 2402

ACM: 广搜 图论题 poj 1708

Game   Description A child has drawn N (N<=100) numbered circles of different colors. He has connected some of the circles by colored oriented line segments. Every pair of circles may have any number

smile_benson 382

杭电1708Fibonacci String

Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4641    Accepted Submission(s): 1566 Problem Description After lit

hpuzsk的博客 1355

杭电ACM-LCY算法进阶培训班-专题训练(4-8-12-16)

入口 1002 I Hate It #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long #define int long long //#define double long double #define eps 1e-8 //#define mod 1e9+7 #define ls

lcl1234567890lcl的博客 483

【ACM】杭电OJ 2007

题目链接:杭电OJ 2007 本题容易出错的地方在于:要考虑输入的两个数的大小,一定是小的在前,大的在后 #include "stdio.h" int main () { int a,b,sum1,sum2,t; while(scanf("%d%d",&amp;a,&amp;b)!=EOF) { if(a&gt;b) { t=a;a=b;b=t; } sum1=0...

( :3 ) 486

hdu1020

Encoding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11421    Accepted Submis

ACM 1521

2019 ACM 算法竞赛世界总决赛成绩排名

排名 参赛队伍所属大学 解题数 1 莫斯科国立大学 10 2 麻省理工学院 9 3 东京大学 9 4 华沙大学(波兰) 8 5 国立台湾大学 8 6 弗罗茨瓦夫大学(波兰) 8 7 首尔国立大学 7 8 金策科技大学(朝鲜) 7 9 沙力夫理工大学(...

Joven0的专栏 1万+
上一篇: 杭电ACM1587 买花,,气人
下一篇: 杭电ACM1718 名次
fackerbang
博客等级 码龄9年 4粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值