//
// main.cpp
// uva 129 - Krypton Factor
//
// Created by XD on 15/7/27.
// Copyright (c) 2015年 XD. All rights reserved.
//
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<vector>
#include <string.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
using namespace std ;
int result[100] ;
int n ;
int l ;
bool isAcceptable(int cur)
{
if(!cur)
{
return true ;
}
int flag = 0 ;
for (int i = 1; 2* i <=cur+1; i++) {
flag = 0 ;
for (int j = cur - i+1 ; j <=cur ; j++) {
if (result[j] != result[j - i]) {
flag = 1 ;
}
}
if (flag == 0 ) {
return false ;
}
}
return true ;
}
int t ;
int solved ;
int fillCache(int cur )
{
if (t++ == n+1 ) {
solved = 1 ;
return cur ;
}
for (int i = 1; i <= l ; i++) {
result[cur] = i ;
if (isAcceptable(cur)) {
int k = fillCache(cur+1) ;
if (solved ==1) {
return k ;
}
}
}
return 0 ;
}
int main() {
while (scanf("%d%d" ,&n,&l)==2) {
solved = 0 ;
if (n + l == 0 ) {
return 0 ;
}
else{
t = 1 ;
int len = fillCache(0) ;
int j = 0 ;
int temp = 0 ;
for (int i = 0; i < len; i++) {
printf("%c" , result[i] + 'A' - 1) ;
temp++ ;
if (temp == 4) {
j++ ;
if (j == 16) {
printf("\n") ;
j= 0 ;
}
else{
if (i==len-1) {
continue ;
}
printf(" ") ;
}
temp = 0 ;
}
}
if (j != 0 || (j == 0&& t != 0)) {
printf("\n") ;
}
printf("%d\n" , len) ;
}
}
return 0;
}
相关推荐
LLC混合滞回控制 vs 电压模/电流模:UCC25640x仿真对比与选型指南
在开关电源设计中,LLC谐振变换器的环路补偿是核心难点。传统电压模控制(VMC)和电流模控制(CMC)在LLC拓扑上存在环路增益漂移、动态响应慢等局限。混合滞回控制通过滞回比较器直接调制开关频率,并融合输出电压与谐振腔电流信息,实现了自适应环路增益和快速瞬态响应。该技术显著提升轻载效率与动态性能,适用于高密度适配器、快充及车载充电机等场景。本文基于UCC25640x系列,通过仿真对比三种控制策略,为工程选型与调试提供实践参考。
例题7-5 UVA129 Krypton Factor(38行AC代码)
紫书刷题进行中,题解系列【GitHub|优快云】 例题7-5 UVA129 Krypton Factor(38行AC代码) 题目大意 用26个大写字母[A,Z]的前L个字母,构造无重复连续子串的字符串,按照字典序排序后,输出第n个字符串 思路分析 本题枚举可重复使用每个元素,若每次都是从小到大的顺序枚举字母,那么就是按字典序升序排列找到的结果,关键在于如何判断无重复连续子串? 如果按照输入样例绘...
手把手排查IOMMU映射故障:从内核日志到硬件寄存器调试全指南
本文详细解析了IOMMU映射故障的排查方法,从内核日志分析到硬件寄存器调试,提供了一套完整的诊断流程。涵盖AMD和Intel平台的特定调试技巧,包括ATS协商失败、DMA传输错误等常见问题的解决方案,并介绍了高级调试工具链的搭建与性能优化策略。
UVa--129 Krypton Factor(DFS)
传送门 题解: LRJ大法。 如何避免相邻的重复子串?每增加一个字符,从长度j(1 # include # include # include using namespace std; int n, L; int S[100]; int cnt; int dfs(int pos) //返回0表示已经得到解,无须继续搜索 { if(cnt++ ==
使用FloodRisk2插件进行洪水风险评估
入汛以来,长江流域持续的强降雨使得沿岸多地成为洪水风险极高地区,抗洪、抢险、救灾继新冠病毒之后成为又一个攻坚阵地。如何科学地评估洪水风险,是快速决策的关键。 实际生活中,根据风险是否可控,一般将洪水风险大致分为两类:一类是通过数据分析可以得出其发生的可能性和后果,如强降雨引发的区域性洪水、水库/大坝溃决洪水等。这类洪水可以通过有关资料分析和设定一定条件计算得到可能的损失后果,也就是说,风险可以预判。另一类洪水风险基本是未知的,如滑坡堵塞河道形成堰塞湖引发的洪水,无法预知事件发生的地点和规模,具体的洪水风险无
Unet++改进33:添加ConvolutionalGLU(2024最新改进方法)|紧凑的网络结构和高效的运算
由于残差连接的深度退化效应,许多依赖堆叠层进行信息交换的高效视觉变形模型往往不能形成足够的信息混合,导致视觉感知不自然。为了解决这个问题,在本文中,我们提出了聚合注意力,这是一种基于仿生设计的令牌混合器,它模拟生物中央凹视觉和连续眼运动,同时使特征映射上的每个令牌具有全局感知。此外,我们结合了可学习的令牌,与传统的查询和键交互,这进一步多样化了亲和矩阵的生成,而不仅仅依赖于查询和键之间的相似性。我们的方法不依赖于堆叠进行信息交换,从而有效地避免了深度退化,实现了自然的视觉感知。
UVa 129 Krypton Factor
本文探讨了如何按字典序生成第n个"困难序列",其定义为不包含相邻相同子串的序列。通过回溯法(DFS)按字典序生成序列,并利用剪枝优化搜索过程。每次添加字符时检查序列合法性,确保不存在相邻重复子串。输出格式要求每4字符一组,组间空格分隔,超过16组时换行。该算法通过合理剪枝保证了效率,适用于L≤26且序列长度不超过80的情况。
RedCap:一种通信技术的概述
总结起来,RedCap是一种基于数据包交换的通信技术,它提供了一种高效、可靠的数据传输机制。通过使用RedCap,我们可以轻松地发送和接收数据包,并确保数据的完整性和正确性。在上面的示例中,我们首先导入了RedCap库,并创建了一个RedCap实例。然后,我们定义了目标地址和源地址,并创建了一个数据包,其中包含了目标地址、源地址和要发送的数据。本文将介绍RedCap的基本原理和使用方法,并提供一些相关的源代码示例。RedCap还提供了其他一些功能,如数据包的重传机制、流量控制和拥塞控制等。
Krypton Factor UVA - 129
题目链接 :https://cn.vjudge.net/problem/UVA-129 题意 : 如果一个字符串包含两个相邻的重复子串,则称它为“容易的串”,否则称为“困难的串”,例如,BB,ABCDABCD,ABCDACABCAB,都是容易的串,而D,ABAC,都是困难的串。输入正整数n,L,让你找出由字母表前L个大写字母组成的字典序第n小的困难的串,并且输出这个串的长度。输出格式请点击上...
TOGAF架构内容—TOGAF 内容框架和企业元模型
TOGAF架构内容—TOGAF 内容框架和企业元模型
【android bluetooth 案例分析 01】【HiCar 详解 3】【hicar时如何交换Wifi参数的】
如果直接使用 L2CAP(不经过 RFCOMM),会需要额外的协议来保证可靠性,而 RFCOMM 天然支持。BLE 广播的数据长度受限(31 字节 / 255 字节扩展),不适合传输复杂的 Wi-Fi 连接参数。使用 RFCOMM 传输参数,可以兼容不同厂商的车机和手机,而无需依赖特殊的蓝牙功能。手机解析这些参数,并使用 Wi-Fi Direct 连接到车机。,然后才能让 Wi-Fi Direct 进行真正的数据传输。,适合传输 Wi-Fi 连接参数等关键数据。,可以安全地交换 Wi-Fi 连接信息。
UVa129 Krypton Factor
回溯法。 使用26个字母中前L个字母,要求输出一个不存在相同的相邻子串的序列,该序列应是所有合法序列中字典序第N小的。 DFS枚举所有可行序列,因为序列长度不定所以解答树中除根节点之外的每个结点都算合法序列,得到N个合法序列后停止枚举。每次填入字符后只需检查刚填入的字符是否形成了一对相同的相邻子串,因为填入前的序列已经被确认过是合法的。 #include <iostream>...
pyradiomics使用——1. 医学影像的组学特征值(Radiomics Features)提取
文章目录1. 使用插件1.1 插件安装1.2 插件使用2. 使用python代码2.1 安装2.2 使用2.2.1 官方示例2.2.2 快速使用2.2.3 其它使用3. 组学特征字段意义说明 Github地址:https://github.com/AIM-Harvard/pyradiomics 官方文档地址:https://pyradiomics.readthedocs.io/en/latest/features.html 1. 使用插件 从pyradiomics的Github仓库中可以知道,pyradio
UVA - 129 Krypton Factor
Description You have been employed by the organisers of a Super Krypton Factor Contest in which contestants have very high mental and physical abilities. In one section of the contest the conte
计算机控制技术及应用
《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
UVA 129_ Krypton Factor
题意: 一个字符串含有两个相邻的重复的子串,则称这个串为容易的串,其他为困难的串,对于给定n,l,求出由前l个字符组成的字典序第n小的困难的串。 分析: 按字典序在字符串末尾增加新的字符,并从当前字符串后缀入手,判断长度为偶数的子串中,是否含有重复的相邻子串。 代码: #include<cstdio> #include<iost...
NTscan扫描工具
ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。
UVA - 129 Krypton Factor
题意:一个字符串,若包含两个连续的相同子串,则为容易的串,如“ABCDBCDE”,否则称为困难的串,给定n和L,输出由前L个大写字母组成的字典序第n小的困难的串。 思路: dfs,每当枚举的字符串是一个复杂字符串时,进入下一个dfs,直到dfs层数到了n时,输出字符串。 判断是否为困难字符串的方法,因为dfs的上一个字符串一定为复杂字符串,所以,只需要判断它的后缀字符串是否与相邻的相等即可。...
VC中sqlite的使用
在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示
UVA-129 Krypton Factor(dfs)
题目链接: UVA-129 Krypton Factor(dfs) 题目大意: 如果一个字符串包含两个相邻的重复子串,则成它是"容易的串",其他串成为"困难的串"例如: BB ,ABCDACABCAB , ABCDABCD 都是容易串,而 D, DC, ABDAB, CBABCBA, 都是困难串. 输入正整数n, l 输出由前l个大写字母组成的,字典序第n小的困难串,例如: 当l
UVA129 Krypton Factor 困难的串 dfs回溯【DFS】
Krypton FactorTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 392 Accepted Submission(s): 174Problem DescriptionYou have been employed by t...
UVA 129 - Krypton Factor
You have been employed by the organisers of a Super Krypton Factor Contest in which contestants have very high mental and physical abilities. In one section of the contest the contestants are tested ...
UVA129-Krypton Factor(搜索剪枝)
Problem UVA129-Krypton Factor Accept:1959 Submit:10261 Time Limit: 3000 mSec Problem Description 通过了光明狮子的考验,小渡来到了创界山的第二层。没想到第二层的守护神——火焰凤凰正沉迷于字母游戏,不能自拔!为了尽快得到她的帮助,小渡决定出手帮她解决字母游戏的谜题。 字母游戏规则...
UVA129 - Krypton Factor
一个回溯的基本题目,简单易理解 // UVA 129 #include #include #include using namespace std; const int maxn=500; int n,l; int s[maxn]; int cnt; void print(int cur){ for(int i=0; i<cur; i++){ if(i%64=
UVA-129 Krypton Factor
You have been employed by the organisers of a Super Krypton Factor Contest in which contestants have very high mental and physical abilities. In one section of the contest the contestants are tested on
E - Krypton Factor UVA - 129
#include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 0x3f3f3f3f int n, l, len, ct; char str[85]; bool flag; bool checkSu
UVA129 —— Krypton Factor (氪因素)
Input and Output In order to provide the Quiz Master with a potentially unlimited source of questions you are asked to write a program that will read input lines that contain integers n and L (in
333



被折叠的 条评论
为什么被折叠?



