POJ 1365 / Central Europe 1997 Prime Land (数论)

基于轻量级神经网络MobileNet V2的水果识别种类算法研究 本文阐述了一种基于轻量级卷积神经网络MobileNet V2的水果分类与识别算法研究。为了最大限度地促进机械收获,需要一个检测系统,它可以让我们识别不同类别的水果。一个相对未开发的想法是使用深度学习和人工智能算法,不仅可以检测水果的种类,还可以检测水果是否成熟。这可以证明是有利可图的,因为它可以提供作物生长状况以及成熟和未成熟果实的个体数量,以及决定是否是收获时间的有用信息。第一步对数据进行了预处理,数据预处理技术在众多的深度学习计算中起到了重要作用。 阅读详情
Prime Land

Time Limit:  1000MS
Memory Limit: 10000K

Description

Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing sequence of all prime numbers. We know that x > 1 can be represented in only one way in the form of product of powers of prime factors. This implies that there is an integer kx and uniquely determined integers e kx, e kx-1, ..., e 1, e 0, (e kx > 0), that   The sequence (e kx, e kx-1, ... ,e 1, e 0) is considered to be the representation of x in prime base number system. 

It is really true that all numerical calculations in prime base number system can seem to us a little bit unusual, or even hard. In fact, the children in Prime Land learn to add to subtract numbers several years. On the other hand, multiplication and division is very simple. 

Recently, somebody has returned from a holiday in the Computer Land where small smart things called computers have been used. It has turned out that they could be used to make addition and subtraction in prime base number system much easier. It has been decided to make an experiment and let a computer to do the operation ``minus one''. 

Help people in the Prime Land and write a corresponding program. 

For practical reasons we will write here the prime base representation as a sequence of such pi and ei from the prime base representation above for which ei > 0. We will keep decreasing order with regard to pi. 

Input

The input consists of lines (at least one) each of which except the last contains prime base representation of just one positive integer greater than 2 and less or equal 32767. All numbers in the line are separated by one space. The last line contains number 0.

Output

The output contains one line for each but the last line of the input. If x is a positive integer contained in a line of the input, the line in the output will contain x - 1 in prime base representation. All numbers in the line are separated by one space. There is no line in the output corresponding to the last ``null'' line of the input.

Sample Input

17 1
5 1 2 1
509 1 59 1
0

Sample Output

2 4
3 2
13 1 11 1 7 1 5 1 3 1 2 1

学英语:
The input consists of lines (at least one) each of which except the last contains prime base representation of just one positive integer greater than 2 and less or equal 32767.
输入有至少一行,除了最后一行,每行都包含了一个数的素因子分解表示,该数大于2且小于或等于32767.

完整代码:
/*0ms,116KB*/

#include<cstdio>
#include<cstring>
#include<cmath>

char s[24];///刚好
int base[6], index[6];///刚好

int main(void)
{
	while (gets(s), s[0] != '0')
	{
		memset(base, 0, sizeof(base));
		memset(index, 0, sizeof(index));
		int temp = 0, count = 0;
		bool which = true;
		for (int i = 0; s[i]; ++i)
		{
			if (s[i] != ' ')
				temp = temp * 10 + s[i] - '0';
			else
			{
				if (which)
					base[count] = temp;
				else
					index[count++] = temp;
				which = (which ? false : true);
				temp = 0;
			}
		}
		///最后s[i] == '\0'退出
		index[count++] = temp;
		int ans = 1;
		for (int i = 0; i < count; ++i)
			for (int j = 0; j < index[i]; ++j)
				ans *= base[i];///整数的幂运算最好用for代替!
		--ans;
		count = 0;
		int sqrtans = (int)sqrt((double)ans);
		for (int i = 2; i <= sqrtans; ++i)
		{
			if (ans % i == 0)
			{
				index[count] = 0;
				base[count] = i;
				while (ans % i == 0)
				{
					++index[count];
					ans /= i;
				}
				count++;
			}
		}
		if (ans > 1) ///无法分解
		{
			base[count] = ans;
			index[count++] = 1;
		}
		///逆序输出
		for (int i = count - 1; i > 0; --i)
			printf("%d %d ", base[i], index[i]);
		printf("%d %d\n", base[0], index[0]);
	}
	return 0;
}

先打表的方法:

/*16ms,128KB*/

#include<cstdio>
#include<cstring>
#include<cmath>

char s[24];///刚好
int base[6], index[6], prime[43], c = 0;
bool vis[192];

inline void create_prime()
{
    for (int i = 2; i <= 191; ++i)
        if (!vis[i])
        {
            prime[c++] = i;
            for (int j = i * i; j <= 191; j += i)
                vis[j] = true;
        }
}

int main(void)
{
    create_prime();
	while (gets(s), s[0] != '0')
	{
		memset(base, 0, sizeof(base));
		memset(index, 0, sizeof(index));
		int temp = 0, count = 0;
		bool which = true;
		for (int i = 0; s[i]; ++i)
		{
			if (s[i] != ' ')
				temp = temp * 10 + s[i] - '0';
			else
			{
				if (which)
					base[count] = temp;
				else
					index[count++] = temp;
				which = (which ? false : true);
				temp = 0;
			}
		}
		///最后s[i] == '\0'退出
		index[count++] = temp;
		int ans = 1;
		for (int i = 0; i < count; ++i)
			for (int j = 0; j < index[i]; ++j)
				ans *= base[i];///整数的幂运算最好用for代替!
		--ans;
		count = 0;
		int sqrtans = (int)sqrt((double)ans);
		for (int i = 0; prime[i] <= sqrtans; ++i)
		{
			if (ans % prime[i] == 0)
			{
				index[count] = 0;
				base[count] = prime[i];
				while (ans % prime[i] == 0)
				{
					++index[count];
					ans /= prime[i];
				}
				count++;
			}
		}
		if (ans > 1) ///无法分解
		{
			base[count] = ans;
			index[count++] = 1;
		}
		///逆序输出
		for (int i = count - 1; i > 0; --i)
			printf("%d %d ", base[i], index[i]);
		printf("%d %d\n", base[0], index[0]);
	}
	return 0;
}


【牛股启动线】副图指标使用技术说明,图文案例分享,通达信炒股指标 如上图,在紫色线在黑色虚线上时,在出现紫色柱线时,通常会出现强势拉升的行情​。柱线加长加上紫色线上扬,进场跟随做多抓强势行情,紫色柱线和紫色线同时做多持续则可以继续持股。如上图,副图指标【牛股启动线】,指标信号包括紫色线走势信号和紫色柱线信号,以及底部的四条虚线技术信号​,还有一条绿色的参考线,一条黑色的虚线两天分档线。如上图,参考买点,紫色柱线开始出现时进场买点,在上图标记的位置对应的就是进场买点​。紫色柱线加长+紫色线上扬,多头共振持股,行情继续拉升阶段,持股待涨或顺势​进场做多。 阅读详情

相关推荐

C语言版数字锁相放大器实现指南:从复数运算到嵌入式MCU移植的坑我都帮你踩了

本文详细介绍了C语言实现数字锁相放大器的关键技术,包括复数运算优化、嵌入式MCU移植的实战经验及内存管理策略。针对STM32等资源受限平台,提供了从浮点到定点数转换的优化方案,帮助工程师高效处理微弱信号提取问题。

weixin_30721077的博客 432

poj1365

Prime Land Description Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increa

◆◇丶生如夏花。谁来订阅我的悲伤 505

USB3.0一致性测试方案

为各测试项目具体测试结果包括脉冲串突发时间、脉冲串重复时间、时钟周期以及眼图等完整USB3.0测试项目,工程师可以看到各项测试的具体结果方便观察。RIGOL 提供了一套完善的工具,包括数字示波器、专业的测试夹具以及全自动一致性测试软件,使得USB 3.0设备设计人员能够高效精确地进行信号捕捉、测试与分析。报告第二部分测试摘要,在此可以看到USB3.0测试所有测试项目,并且可以观看到测试是否正常,可以帮助工程师更好的判断测试结果。,以简化下载、存储以及对于多媒体的大量内容的共享。

2409_87378937的博客 2530

PKU 1365 Prime Land

<br />内存限制10000k,错看成了1000k,一边骂POJ不厚道一边千方百计缩略mem开支,耽误良久,RE良久。艹<br />素数筛选 + 素因子拆分<br />#include <pzjay_cpy> using pzjay:space std; const int sup =4300;//预留sup个位置,略大于oo范围内生成的实际素数个数 const int oo = 40000; bool isp[oo + 10]; int prime[sup]; int x; int ans

Belong to Sopranos 1123

SAP MTS计划策略40实战:如何配置‘带最终组装的计划‘提升定制化生产效率

本文深入解析SAP计划策略40(带最终组装的计划)的核心机制与实战配置。该策略通过“需求消耗”与“组装灵活性”,有效融合按库存生产(MTS)与按订单生产(MTO)的优势,帮助制造企业在保持通用组件库存稳定的同时,快速响应客户的定制化需求,从而提升生产效率与客户满意度。

ruby5的博客 967

SAP Parallel Accounting(平行分类账业务)配置及操作手册【适用于多国家会计准则】

在SAP系统中,分类账(Ledger)是用于会计核算的核心概念,它允许企业根据不同的会计原则和货币进行财务记录。定义分类账是配置平行账(Parallel Accounting)的第一步。分类账的创建:通过事务代码OX18可以创建新的分类账。通常,一个SAP系统会有一个主分类账(如0L),它代表法定会计和实时传输至管理会计(CO)的账本。分类账属性:在创建分类账时,需要定义其属性,如会计年度变式、货币、会计原则等。这些属性将决定分类账的核算规则和适用性。

数字化2025 4617

数学--数论--POJ1365——Prime Land

Description Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing sequence of al...

日拱一卒,功不唐捐 2874

Unity序列帧动画输出全攻略:Recorder+Timeline实战与透明通道处理

序列帧动画是游戏开发、影视动画和UI动效中的基础技术,指将连续动作分解为一系列静态图像并按序播放,形成动态视觉效果。其原理是通过时间轴精确控制每一帧的内容与时机,实现动画的逐帧呈现。在实时渲染领域,序列帧输出技术价值显著,它能够将动态内容高质量地转换为静态图像序列,便于跨平台复用、后期合成与资源分发。应用场景广泛,包括角色动画导出、技能特效制作、宣传片素材生成等。本文聚焦Unity引擎,深入解析如何利用Recorder与Timeline工具链,高效输出带Alpha透明通道的PNG序列帧,并重点攻克透明通道处

weixin_31556767的博客 327

pku1365 Prime Land (数论,合数分解模板)

题意:给你一个个数对a, b 表示ab这样的每个数相乘的一个数n,求n-1的质数因子并且每个指数因子k所对应的次数 h. 先把合数分解模板乖乖放上: for (int i = 2; ans != 1; ++i) { if (ans%i == 0) { num[cnt] = i; i...

weixin_33985507的博客 166

Arcgis使用NDVI值遥感反演叶面积指数(LAI)

经验模型反演操作不难,主要是要多看文献,了解公式。本文中的公式我也不清楚是哪个作物的NDVI和LAI的关系(别人提供的),继续看文献整理吧。后续会在下面罗列更新一下主要公式。

所有专家都曾始于新手 8430

【Frida Android】实战篇8:客户端证书认证绕过 Hook 教程

通过重写类的方法,自定义证书校验逻辑;利用配置文件,从系统层面管理证书信任策略;以及通过 OkHttp 框架提供的方法,实现证书的强绑定校验。这些内容主要围绕客户端如何验证服务端证书的合法性展开。客户端证书认证。当 APK 预置了客户端证书,并且服务端会对客户端证书进行校验时,传统的中间人攻击方式将面临新的挑战。我们将深入分析这种场景的工作原理,并详细介绍如何通过技术手段获取客户端证书、配置中间人工具,最终成功实现抓包分析。

水滴石穿 1427

POJ1365——Prime Land(素数筛选加暴力)

题目链接      这是一道素数的水题,唯一的难点就是理解题意,大致是说给你一列数,a1,a2,a3,a4,a5,a6,.......然后按(a1^a2)*(a3^a4)*(a5^a6).......得到一个和值sum,然后把sum-1,再按(a1^a2)*(a3^a4)*(a5^a6).......的格式对sum-1分解质因式,比如样例中的5 1 2 1,就得到sum=5^1+2^1=10,然

Jason_crawford的博客 890

军品研制过程-转阶段

介绍军品转阶段评审

Abel的博客 2万+

【poj 1365】 Prime Land 【Central Europe 1997】

Description Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing sequence of

TLECODE的博客 375

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

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

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

POJ 1365 Prime Land(整数拆分)

  题意:感觉题意不太好懂,题目并不难,就是给一些p和e,p是素数,e是指数,然后把这个数求出来,设为x,然后让我们逆过程输出x-1的素数拆分形式,形式与输入保持一致。   思路:素数打表以后正常拆分即可。   注意:输入过程需要优化,我以前经常使用字符串模拟的方式,后来发现那种方法比较笨,还是下面的方法简洁;代码如下:    #include<iostream> #in...

weixin_30677617的博客 159

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

poj1365 整数分解(质因数分解)

题意:给出一个数x的质因数表达式,请你算出x-1的质因数表达式 分析: 首先求出x,然后对x-1进行整数分解(质因数分解),整数分解可以直接套模板。 在处理过程中,发现用int定义x和y时,用pow函数运算时会造成数据丢失,因此用double定义。 首先看质因数分解模板: //摘自《挑战程序设计竞赛》p118 map prime_factor(int n) { map

天行健,君子以自强不息 1494

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

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

HIT OJ 1069 哈工大

Prime Land Source : ACM ICPC Central European Regional 1997 Time limit : 1 sec Memory limit : 32 M Submitted : 238, Accepted : 133 Everybody in the Prime Land is ...

lilisalo 287

POJ 1365 Prime Land 【素数分解】

Description Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing sequence of a

咸鱼の小窝 777

poj 1365

<br /> Prime LandTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1246 Accepted: 556<br />DescriptionEverybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,

neoxuhaotian的专栏 1545

1月22号acm寒假训练第二题

Time limit2000 msMemory limit262144 kBSourceCodeforces Beta Round #57 (Div. 2)Tagsimplementation *900EditorialAnnouncement Tutorial #1 Tutorial #2 Tutorial #3 Tutorial #4 Tutorial #5 problem descripti...

weixin_44009750的博客 470

Problem--61A--Codeforces--A. Ultra-Fast Mathematician

A. Ultra-Fast Mathematician time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Shapur was an extremely gifted student. He wa

qq_36667106的博客 781

POJ 1365 Prime Land

Prime Land Time Limit:1000MS Memory Limit:10000K Total Submissions:2972 Accepted:1362 Description Everybody in the Prime Land is using a prime base numb...

weixin_30929011的博客 116

POJ 1365 Prime Land(质因数分解)

Prime Land Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3845 Accepted: 1728 Description Everybody in the Prime Land is using

wchhlbt的博客 774

HDU 1335 Basically Speaking (模拟进制转换)

Basically Speaking Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2909    Accepted Submission(s): 1129 Problem Description The Really

LzyRapX 935

B - Ultra-Fast Mathematician

Problem description Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraor...

weixin_30510153的博客 134

坑爹水题——Uva10036

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=976&mosmsg=Submission+received+with+ID+11932248 Problem B: Primary Arithmetic Ch

CS_liuqing的专栏 1766
上一篇: 类型转换与字符串赋值、分割、合并、复制、比较、查询、翻转详解 (完整代码)
下一篇: POJ 1033 / Northeastern Europe 1998 Defragment (模拟&队列)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值