USACO section 1.5 Superprime Rib(深搜)

[USACO13FEB]Perimeter【DFS / 深搜】 Pro Luogu3072 Sol 这题的话,我就把我的想做当做反例给说一下。 错误想法:很容易的发现,一个不规则的图形,我们可以通过转换为规则的矩形来求周长,可以平移一些边来求得,但是存在反例。 如图,蓝色为草堆。如果我们按照边平移转换为规则的矩形求得话,答案就是161616,但我们会发现,那块空白的区域的两条边没有算进去,所以正确答案应该是181818。 正解:既然只有一个... 阅读详情

Superprime Rib

Butchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. Farmer John ensures that a purchaser of his prime ribs gets really prime ribs because when sliced from the right, the numbers on the ribs continue to stay prime right down to the last rib, e.g.:

     7  3  3  1

The set of ribs denoted by 7331 is prime; the three ribs 733 are prime; the two ribs 73 are prime, and, of course, the last rib, 7, is prime. The number 7331 is called a superprime of length 4.

Write a program that accepts a number N 1 <=N<=8 of ribs and prints all the superprimes of that length.

The number 1 (by itself) is not a prime number.

PROGRAM NAME: sprime

INPUT FORMAT

A single line with the number N.

SAMPLE INPUT (file sprime.in)

4

OUTPUT FORMAT

The superprime ribs of length N, printed in ascending order one per line.

SAMPLE OUTPUT (file sprime.out)

2333
2339
2393
2399
2939
3119
3137
3733
3739
3793
3797
5939
7193
7331
7333
7393

 
 
 
 
/*
ID:nealgav1
PROG:sprime
LANG:C++
*/
#include<cstdio>
#include<cmath>
int m;
bool isprim(int num)//判断质数
{
  if(num==2)return 1;
  if(num&1)
  {
    int n=(int)sqrt(num);
    for(int i=3;i<=n;i+=2)
    if(!(num%i))
    return 0;
    return 1;
  }
  return 0;
}
void dfs(int num,int n)
{
  int ans;
  if(m==n)
  {
    printf("%d\n",num);
    return;
  }
  for(int i=1;i<=9;i+=2)
  {
    ans=num*10+i;
    if(isprim(ans))
    dfs(ans,n+1);
  }
}
int main()
{
  freopen("sprime.out","w",stdout);
  freopen("sprime.in","r",stdin);
  scanf("%d",&m);
  dfs(2,1);dfs(3,1);dfs(5,1);dfs(7,1);
}
 
 
 
 
 
 
USER: Neal Gavin Gavin [nealgav1]
TASK: sprime
LANG: C++

Compiling...
Compile: OK

Executing...
   Test 1: TEST OK [0.000 secs, 3344 KB]
   Test 2: TEST OK [0.000 secs, 3344 KB]
   Test 3: TEST OK [0.000 secs, 3344 KB]
   Test 4: TEST OK [0.000 secs, 3344 KB]
   Test 5: TEST OK [0.000 secs, 3344 KB]

All tests OK.

Your program ('sprime') produced all correct answers! This is your submission #2 for this problem. Congratulations!

Here are the test data inputs:

------- test 1 ----
4
------- test 2 ----
5
------- test 3 ----
6
------- test 4 ----
7
------- test 5 ----
8
Keep up the good work!


Thanks for your submission!

 

 

Super Prime RibRuss Cox

We use a recursive search to build superprimes of length n from superprimes of length n-1 by adding a 1, 3, 7, or 9. (Numbers ending in any other digit are divisible by 2 or 5.) Since there are so few numbers being tested, a simple primality test suffices.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

FILE *fout;

int
isprime(int n)
{
	int i;

	if(n == 2)
		return 1;

	if(n%2 == 0)
		return 0;

	for(i=3; i*i <= n; i+=2)
		if(n%i == 0)
			return 0;

	return 1;
}

/* print all sprimes possible by adding ndigit digits to the number n */
void
sprime(int n, int ndigit)
{
	if(ndigit == 0) {
		fprintf(fout, "%d\n", n);
		return;
	}

	n *= 10;
	if(isprime(n+1))
		sprime(n+1, ndigit-1);
	if(isprime(n+3))
		sprime(n+3, ndigit-1);
	if(isprime(n+7))
		sprime(n+7, ndigit-1);
	if(isprime(n+9))
		sprime(n+9, ndigit-1);
}

void
main(void)
{
	int n;
	FILE *fin;

	fin = fopen("sprime.in", "r");
	assert(fin != NULL);
	fout = fopen("sprime.out", "w");
	assert(fout != NULL);

	fscanf(fin, "%d", &n);

	sprime(2, n-1);
	sprime(3, n-1);
	sprime(5, n-1);
	sprime(7, n-1);
	exit (0);
}


 

为什么桥式传感器(Bridge Sensor)需要用到仪表放大器? 仪表放大器在桥式传感器的应用里起到关键作用,本文介绍桥式传感器的原理、特性,以及信号调理过程,并附上了一个 TINA - TI 的仿真电路。 阅读详情

相关推荐

工程制图习题集张大庆课后习题答案解析

所以,我想向大家求助,希望能得到一些学习资料、学习方法和学习经验,帮助我更好地理解和掌握这门课程。在寻找学习资料的过程中,我发现了一款叫做资小料的APP,它里面有很多关于工程制图的学习资料,包括视频教程、习题解答和考试真题等。通过使用资小料,我逐渐掌握了工程制图的基本理论和方法,解决了很多学习中遇到的问题。在这里,我想推荐给和我一样在学习《工程制图习题集》这门课的同学们,希望大家也能从这款APP中受益,共同进步。上传者: 『Consentesdei』蒼迷穀。出版社: 清华大学出版社。

weixin_58833001的博客 940

USACO-Section2.1 The Castle (深度优先搜索)

2017-8-3 题目描述 知道城堡有多少个房间,每个房间有多大 把一面单独的墙(指两个单位间的墙)拆掉以形成一个更大的房间 解答 代码写的好长... 代码 /* ID: 18795871 PROG: castle LANG: C++ */ #include&lt;iostream&gt; #include&lt;cstring&gt; #include&lt;fstrea...

qq_34600424的博客 361

zynq+LWIP 裸机双网口实现(MIO+EMIO)+程序下载

芯片型号: ZYNQ: XC7Z010clg400开发软件:Vivado2022 + Xilinx Vitis 2022网卡芯片:RTL8211FDI(需要根据网口芯片型号修改对应的硬件配置代码。

thinking in 小宇宙 3430

USACO-Section1.5 sprime[深搜]

题目大意: ,举例来说: 7331是质数; 733是质数; 73 是质数; 7 也是质数。 7331 被叫做长度 4 的特殊质数。 写一个程序对给定的数目 N (1<=N<=8),求出所有的特殊质数。 数字1不被看作一个质数。 样例输入: 4 样例输出: 2333 2339 2393 2399 2939 3119 3137 3733

mujinuist的博客 341

二维紧束缚模型求解程序

假如我们已经推导出了二维紧束缚模型的哈密顿量矩阵H(kx,ky)的解析形式,那么在整个布里渊区对角化矩阵就可以得到能带。从技术上说这里面有以下几个问题。 1. 缺少实空间和倒空间的坐标,使得能带难以和布里渊区高对称点对应。 2. 最容易处理的布里渊区是矩形,对于其他多边形,如果全布里渊区mesh画费米面有一定技术困难。 因此一个好的处理框架是首先给出实空间原子坐标,给出实空间哈密顿量,...

wwxy1995的博客 4090

从零部署奥比中光Gemini335L:Python SDK编译与手眼标定环境实战

本文提供了一份从零部署奥比中光Gemini 335L深度相机的完整实战指南。详细介绍了驱动安装、Python SDK编译、CMake配置及虚拟环境搭建等关键步骤,并重点解析了如何通过编译生成Python模块,最终实现深度图与点云数据获取,为后续的机械臂手眼标定工作奠定坚实基础。

weixin_29031161的博客 407

USACO 2018 February Contest, Bronze 2 Hoofball 深搜+思维

http://www.usaco.org/index.php?page=viewproblem2&amp;cpid=808 确定好每个点按照题目规则会通向哪里,然后用in数组记录那些没有入度的点。 第一次循环从那些没有入度的点开始进行搜索。每个点传一个球。 第二次循环发现的点,将会是那些两个点一组的环,它们都有入度,但并不和之前搜索过的点想连。给每个环传一个球。 #include &lt;...

西瓜不甜的博客 1004

中国区ASP服务性规范考试

10、每次现场维护服务,工程师需按照400要求达到现场的时间与客户联系,在抵达现场、故障恢复后两个时间点分别向400报CALL ,如与客户联系变更到现场时间点,也需向400电话备案(400-822-9999)……20、工程师小B 在接到客户故障申报后赶到客户现场,发现问题无法解决,于是及时将情况反馈至技术支持响应工程师小C ,小B 就和小C 协商由小C 远程解决此问题,后小B 离开客户现场。18、小L 到客户现场交付安装服务。6、EPMS 中上载初验证书的命名规则为:合同号+初验的客户签署日期……

2301_76197693的博客 1950

USACO-Section1.5 Mother's Milk (深度优先搜索)

2017-8-1 题目描述 给你三个容器,初始时前两个为空,最后一个为满,理想状态下,求当第一个容器 为空时,最后一个容器所剩的所有可能性 解答 (1)只能有牛奶的倒给未满的 (2)避免陷入死循环-&gt;记录出现过的情况 代码 /* ID: 18795871 PROG: milk3 LANG: C++ */ #include&lt;iostream&gt; #includ...

qq_34600424的博客 259

【软件定义汽车】-【架构篇】-全面讲解整车电子电气架构演进

前言: 前段时间,陆陆续续写了一些电子电气架构相关的文章。这里打算再写最后一篇作为收尾,为整个系列画上句号,把坑填上,这个话题就算过去了。后续一段时间,尽量把之前文章中挖的“坑”填一下。行文逻辑将借鉴5W2H进行。 另外,本文作为一篇整合性的文章,为保证逻辑的完整性,主要是将大量过去自己文章中的内容进行梳理整合,也存在很多行业内专家的公开文章的内容,请见谅。 WHAT1:什么是汽车电子电气架构? 电子电气架构:EEA,Electrical/Electronic Architecture.

零点壹客的博客 1万+

【OpenCV-Python】——图像处理基础&读写及显示图像&读写及播放视频&灰度图/彩色图/图像通道操作、运算

在Python中,OpenCV使用NumPy数组存储图像,Numpy是使用Python进行数组计算的软件包,提供强大的N维数组对象,支持复杂的广播功能(数组运算),集成了C/C++和Fortran代码工具,支持线性代数、傅里叶变换和随机数等特性,还可作为通用数据的高效多维容器,如在OpenCV中显示图像。Numpy的知识点见数据处理专栏,主要包括数据类型、创建数组、数组形状、索引切片和迭代、数组运算等。作为初学者,里面可能有总结不全,后续深入学习后会改善文章!下次学习图形用户界面!

weixin_51658186的博客 2091

USACO-section1.5 Superprime Rib[深搜]

题意: 给定n位数,第一位,12位,123位······全是素数 如7333,7,73,733,7333都是素数题解: 深搜:类似于从左往右拼接的想法,当左边是素数后再拼一位数,判断是否进入下一步/* ID:jsntrdy1 PROG:sprime LANG: C++ */ #include<cstdio> #include<iostream> #include<cstring> #incl

buxizhizhou__的博客 347

【深度学习新浪潮】Score Matching(分数匹配):原理、推导与PyTorch实战

在概率模型训练中,配分函数(归一化常数)是绕不开的难题——尤其是能量模型(EBM)、扩散模型等未归一化模型,直接计算配分函数几乎不可能。Score Matching(分数匹配)作为一种无归一化的参数估计方法,通过拟合概率密度的对数梯度(分数函数),彻底避开了配分函数的计算,成为生成建模、密度估计的核心技术之一。本文将从基础概念出发,逐步推导Score Matching的核心公式,并结合PyTorch实现一个可直接运行的实战案例,帮你彻底理解这一关键技术。Score Matching的核心是。

专注:太空算力、AI infra、异构调度、大模型成本工程 260

USACO section 1.5.3 SuperPrime Rib

USACO section 1.5.3 SuperPrime Rib 1. 从数学的角度: 1.首位只能是质数2 3 5 7 2.其余位只能是1,3,7,9 3.若n=1,直接输出2,3,5 7 直接DFS 1~9,加入当前数末尾,并判断是不是素数,是则递归...

dayong9372的博客 176

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

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

USACO SECTION 1.5 Superprime Rib

Superprime Rib Butchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. Farmer

432

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

USACO section1.5 Superprime Rib

Superprime Rib Butchering Farmer John's cows always yields the best prime rib. Youcan tell prime ribs by looking at the digits lovingly stamped acrossthem, one by one, by FJ and the USDA. Farmer

252

IEM模型,地表粗糙度模拟

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

USACO Section 1.5 Superprime Rib

/* ID: lucien23 PROG: sprime LANG: C++ */ #include #include #include #include using namespace std; set primes;//10000以内的素数 bool isPrime(int num); int main() { ifstream infile("sprime.in"); ofstream

程序缘 1156

USACO Section 1.5 Superprime Rib(dfs)

Superprime Rib Butchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. ...

angtongyou1893的博客 182

USACO-Section1.5 Superprime Rib

2017-07-19题目大意: 农民约翰的母牛总是产生最好的肋骨。 你能通过农民约翰和美国农业部标记在每根肋骨上的数字认出它们。 农民约翰确定他卖给买方的是真正的质数肋骨,是因为从右边开始切下肋骨,每次还剩下的肋骨上的数字都组成一个质数,举例来说: 7 3 3 1 全部肋骨上的数字 7331是质数;三根肋骨 733是质数;二根肋骨 73 是质数;当然,最后一根肋骨 7 也是质数。 7331 被叫

Jane_96的博客 505

Usaco Training Section 1.6 Superprime Rib

让你求n位数中的超级素数(sp)。(如7331,7331、733、73、7都是素数,7331就是sp) 这题我写了三个版本。第一个版本是线性筛,求出所有素数,判断前缀是否为素数。但打完自测时发现会超时,换了第二个版本。第二个版本就是暴力。暴力枚举所有n位数,再判断。打了一半突然想到第三种做法。因为sp有一个性质:一个sp的前缀肯定也是sp。于是我们可以用构造的方法。一位的sp只有2,3,5,7。...

Monster的博客 318

USACO Section 1.5 Superprime Rib - 构造数列

这题直接来枚举再判断显然是效率很低的...我是采取构造的方法...首先将2,3,5,7入队列..然后每次从队头取出一个数..枚举再他后面加1~9后还是不是质数..是的话入队...     当然从队头每次取出一个数后...判断下其位数~~若是等于要求的长度就直接输出了..并且因为构造的时候就保证了其顺序...所以输出顺序也会是满足要求的... Program: /* ID: zzyzz

zzyzzy12 745

USACO-Section 1.5 Superprime Rib(Miller-Rabin)

从最高位开始判断,由于一位数只有2,3,5,7是素数,所以枚举最高位,然后接下来每一位都必须是奇数,所以枚举1,3,5,7; 递归停止条件是:当前数不是素数 或 当前数是素数且是n位书

idealism_xxm的专栏 575

USACO-Section1.5 Superprime Rib[其他][暴力枚举]

2017-5-30题目寻找超级素数,比如7331,本身是素数,733也是,73和7都是,那么它就符合条件。比如四位数的超级素数有: 2333 2339 2393 2399 2939 3119 3137 3733 3739 3793 3797 5939 7193 7331 7333 7393 输入n表示n位数,输出所有可能。题解有了上一题的经验,我根本就不想搞什么素数

xcwhkh的博客 386

USACO - Chapter1 Section 1.5 - Superprime Rib

Superprime Rib

zhuo1ang的博客 283
上一篇: USACO section 1.5 Prime Palindromes(模拟)
下一篇: USACO section 1.5 Checker Challenge(dfs深搜)
剑不飞
博客等级 码龄15年 86粉丝 505原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址