PAT甲级1058,1059

【SWPUCTF 2021 新生赛】hardrce 对每个字符的ASCII值进行按位取反操作(这种要进行自增马进行绕过。 阅读详情

1058 A+B in Hogwarts (20 point(s))

If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enough." Your job is to write a program to compute A+B where A and B are given in the standard form of Galleon.Sickle.Knut (Galleon is an integer in [0,10​7​​], Sickleis an integer in [0, 17), and Knut is an integer in [0, 29)).

Input Specification:

Each input file contains one test case which occupies a line with A and B in the standard form, separated by one space.

Output Specification:

For each test case you should output the sum of A and B in one line, with the same format as the input.

Sample Input:

3.2.1 10.16.27

Sample Output:

14.1.28

题目大意:自定义一个结构的运算,实现这个运算。a.b.c这样一个结构,第一个数范围是0到10的七次方,b是17,c是29

进位搞一下。

解题思路:水是很水,但我还是WA了一发,不知道为什么,第一个数范围明明是有限制的,为什么不考虑溢出的,我现在也不是很懂为什么错。。反正不考虑溢出就对了。

#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<math.h>
#include<set>
#include<list>
#include<climits>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
#include<string>
using namespace std;
int main()
{
	int a, b, c, a1, b1, c1;
	scanf("%d.%d.%d %d.%d.%d", &a, &b, &c, &a1, &b1, &c1);
	int resa, resb, resc;
	resc = (c + c1) % 29;
	resb = (b + b1 + (c + c1) / 29) % 17;
	resa = (a + a1 + (b + b1 + (c + c1) / 29) / 17);
	printf("%d.%d.%d\n", resa, resb, resc);
	return 0;
}

1059 Prime Factors (25 point(s))

Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​.

Input Specification:

Each input file contains one test case which gives a positive integer N in the range of long int.

Output Specification:

Factor N in the format N = p​1​​^k​1​​*p​2​​^k​2​​*…*p​m​​^k​m​​, where p​i​​'s are prime factors of N in increasing order, and the exponent k​i​​ is the number of p​i​​ -- hence when there is only one p​i​​, k​i​​ is 1 and must NOT be printed out.

Sample Input:

97532468

Sample Output:

97532468=2^2*11*17*101*1291

题目大意:实现一下质因数分解。

解题思路:其实一开始看到这题目脑子里出现的就是打表了。。毕竟运行时间是在你进行输入后开始计算的是吧。后来又想了一下。。long int 能分解的质数最大也就10位吧,直接一个个判断上去不就行了,还搞什么素数判定,直接从2开始分解,不可能存在整除不是质因子的结果呀。

#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<math.h>
#include<set>
#include<list>
#include<climits>
#include<queue>
#include<cstring>
#include<map>
#include<stack>
#include<string>
using namespace std;
int main() {
	long int n;
	scanf("%ld", &n);
	if (n == 1)printf("1=1\n");
	else {
		printf("%ld=", n);
		bool flag = true;
		long int curcount = 0;//次数
		long int curprime = 2;//素数
		while (n > 1) {
			while (n%curprime == 0) {
				curcount += 1;
				n /= curprime;
			}
			if (curcount >= 1) {
				if (flag) {
					flag = false;
				}
				else printf("*");
				printf("%ld", curprime);
				if (curcount >= 2)
					printf("^%ld", curcount);
			}
			curprime++;
			curcount = 0;
		}
		printf("\n");
	}
	
	return 0;
}

 

工业激光器核心参数详解与选型实战:从理论到产线落地(五) 本文深入解析了脉冲激光加工的三大核心参数——脉宽、重复频率和脉冲能量的协同作用机制。通过公式推导和产线案例,揭示了参数设置对加工良率的关键影响:1. 脉宽决定热影响区大小,缩短脉宽可显著提升加工精度;2. 重复频率影响加工速度和热积累效应,需平衡效率与质量;3. 脉冲能量决定材料去除量,过大易导致加工缺陷。文中以ABS塑料打标、模具清洗和微孔钻孔为例,展示了参数优化如何将良率从65%提升至99%,并提供了不同应用场景的参数选型表和调试技巧,强调峰值功率比平均功率更具决定性作用。 阅读详情

相关推荐

抖音私信卡片私信名片的原理分析

简单说一下它的功能吧:抖音私信卡片,解决了客户封号严重、引流效率低的痛点,所以从去年到现在,依然是热销品。"抖音快手私信名片链接跳转"是2022年抖音快手引流最新技术,可以生成卡片链接,支持标题、描述、logo以及跳转落地页的完全自定义配置.支持微信公众号和微信号复制唤起微信客户端app添加,同时也支持任意链接落地页跳转提高粉丝引流转化率,关注转化率,引流转化率,安全绿色私信卡片功能1、跳转微信用户点击卡片,自动跳转微信界面,显示好友和群聊二维码2、跳转链接用户点击卡片,自动跳转到指定链接,支持任意链接。3

m0_71385839的博客 5198

PAT甲级1058答案(使用C语言)

题目描述 If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twenty-nine Knuts to ...

weixin_43222033的博客 655

从零开始搭建一个高性能电流镜:手把手教你设计Wide-Swing Cascode结构

本文详细解析了Wide-Swing Cascode电流镜的设计原理与实战流程。针对低压高性能模拟电路设计的核心挑战,文章手把手指导如何从理论分析、参数计算到仿真验证,搭建一个兼具高输出阻抗和低输出电压裕度的电流镜结构,并深入探讨了偏置电路生成、性能优化及版图匹配等关键要点。

weixin_29294975的博客 641

PAT甲级题解 1059

注意范围 #include<bits/stdc++.h> using namespace std; const int MAXN = 100010; struct node { int x; int cnt = 0; }fac[10]; int num = 0; int prime[MAXN]; bool is_prime(int n) { if(n <= 1) { return false; } else if(n ==

zmh657628320的博客 137

Voronoi算法构建多晶

孪晶多晶 采用孪晶的原子链作为种子通过voronoi算法可以得到孪晶多晶结构。 孪晶种子: txt文件不需要特殊设置 box 150 150 150 random 8 得到孪晶多晶: 通过改变孪晶种子的长度可以得到不同孪晶片层厚度的多晶。 准二维柱晶 所有晶粒在某一维度的晶向一致,晶粒仅在平面内具有旋转关系,所有晶界为旋转对称晶界,这种结构的多晶其位错滑移在某些方向受限,但是能极大的提高晶粒...

yamatachi的博客 5286

尚硅谷Redis 7学习笔记

尚硅谷Redis 7学习笔记

不更了,主打一个陪伴 2万+

1058. A+B in Hogwarts (20)- PAT

1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue If you are a fan of Harry Potter, you would

兵临城下 1354

vivado 编译ADI AD9361 TCL脚本生成hdl工程

(4)输入"source ../../scripts/adi_make.tcl"命令(仅双引号内部命令,不包含双引号),个人理解:该命令用来加载当前所需要编译工程所需要各功能模块的信息,因为每个工程需要不同的功能模块,比如有的需要gpio模块,有的不需要gpio模块,这些模块上前面路径的library也同样以TCL脚本形式存在,当有需要时才进行编译,怎么知道当前工程需要什么模块呢就是通过"source ../../scripts/adi_make.tcl"(仅双引号内部命令,不包含双引号)命令实现。

weixin_40586423的博客 821

PAT甲级1058(进制转换的“/” ,“%”干货!)

题目 1058 A+B in Hogwarts(20 分) If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleo...

小夏要科学进步 354

Python Opencv cv2提取图像中某种特定颜色区域(例如黑字白纸背景下的红色公章提取),并将纯色背景透明化

拜拜PHOTOSHOP- 领导突然让我帮他把公章从图片中抠出来,在确保了不是要做坏事的情况下,我打开了PHOTOSHOP,用魔棒工具一点一点抠,但由于魔棒工具的原理是对比临近区域像素差值,导致封闭字体中的区域无法剔除,而且一点一点抠非常麻烦,愤而PYTHON,使用CV2完美解决。 效果如下(马赛克是我添加的): 任务就是把蓝色的公章抠出来。 效果如上。 代码如下: import cv2 import numpy as np src = cv2.imread(r"imagepath")#这里填你的原图像路

qq_43670549的博客 1万+

开发板的使用

一、开发板使用学习大纲。 1、开发板组成、核心板资源,底板资源。 2、开发板连接、调试工具、串口参数配置。 3、开发板启动过程。 4、文件传输 1)使用串口传输。 上传/下载 2)使用网口传输。 上传/下载 5、临时/永久配置开发板IP地址。 6、开发板启动脚本。 二、开发板的组成。 核心板: CPU处理器: 芯片:S5P6818(三星) 内核: ARM cortex-A53 -> 八核处理器 运行内存:512MB*2=1G nandflash:4G 底板: 电源线:5V 串口...

qq_45633736的博客 2667

PAT 甲级1059题

该题的第四个测试点是数字1,要考虑这种情况,刚开始我没考虑,结果就这一个测试点没过,后来想想极端数据,然后试了试,发现这个测试点是数字1. ...

qwe1765667234的博客 329

STM32CubeMX配置FSMC驱动外部SRAM全流程详解

FSMC(灵活静态存储控制器)是STM32实现高速并行外部存储扩展的核心外设,其本质是将片外SRAM地址空间映射为CPU可直接读写的内存区域。原理上依赖于精确的时序寄存器配置(如BTRx)、GPIO复用功能启用及AHB3总线时钟同步机制,技术价值在于免DMA搬运的零拷贝访问能力与确定性低延迟。典型应用场景包括工业HMI缓存、医疗设备实时数据采集、嵌入式图形加速等对带宽和确定性要求严苛的系统。本文围绕STM32F407ZG平台,结合STM32CubeMX工程化配置、硬件信号完整性设计与HAL库底层映射逻辑,系

weixin_34718952的博客 239

PAT 1058选择题的代码实现及错误分析(C语言)

题目 批改多选题是比较麻烦的事情,本题就请你写个程序帮助老师批改多选题,并且指出哪道题错的人最多。 输入格式: 输入在第一行给出两个正整数 N(≤ 1000)和 M(≤ 100),分别是学生人数和多选题的个数。随后 M 行,每行顺次给出一道题的满分值(不超过 5 的正整数)、选项个数(不少于 2 且不超过 5 的正整数)、正确选项个数(不超过选项个数的正整数)、所有正确选项。注意每题的选项从...

bawangtu的博客 1416

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

PAT 甲级1059 Prime Factors

1.问题描述: 题目意思是给定一个整型范围内的n求出这个n能够分解的质因数,若某一个质因子的分解个数超过一个那么使用^次方表示,比如4 = 2 * 2就要写成4 = 2 ^ 2.这样的形式。 2.算法分析: 其实这一道题目是一道纯数学知识题,首先我们要理解质因子,质数就是素数,我们需要先用线性筛筛出一定范围的素数,打个表。这里给出埃式筛法,时间复杂度为O(nlogn) #include &lt;...

ly's Blog 601

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

PAT甲级 1059 Prime Factors (25 分)素数表的建立

1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​. Input Specifi...

qq_29762941的博客 603

Camera2Demo

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

浙大PAT甲级 1059

分解因式题,可先筛选素数,再进行遍历判断。 AC代码:#include #include #include #include #include #include #include #include #include #include #include using namespace std; int mark[100000]; int prime[100000]; int num=0; void

威的博客 460

PAT_1059: Prime Factors

Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1* p2^k2 *…*pm^km. Input Specification: Each input file contains one test ca

badmartin的技术世界 956

1059. Prime Factors (25)-PAT甲级真题(素数表的建立)

1059. Prime Factors (25)Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km. Input Specification: Each input f...

柳婼 の blog 3340

PAT甲级1059 Prime Factors (25 分)

1059Prime Factors(25分) Given any positive integerN, you are supposed to find all of its prime factors, and write them in the formatN=p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​. Input Specifi...

Dexter 326

PAT甲级1058 A+B in Hogwarts

题目: 哈利波特货币体系,Galleon.Sickle.Knut,计算A+B。其中Galleon属于[0,107],Sickle属于[0,17),Knut属于[0,29) 输入格式: 每个输入文件包含一个测试用例,该测试用例占用一行标准格式的A和B,用一个空格隔开。 输出格式: 对于每个测试用例,您应该以与输入相同的格式在一行中输出A和B的总和。 输入样例: 3.2.1 10.16.27 输出样例: 14.1.28 AC代码: (解法1:位数进位) #include<iostream> u

weixin_44404366的博客 276

PAT甲级题目1059 Prime Factors

题目大意: 给出一个整数,让你求出他的所有质因子。 代码: #include<stdio.h> #include<math.h> #define MAXN 100001 bool isprime[MAXN]; int prime[MAXN]; int pnum=0; void getPrime() { for(int i=0;i<MAXN;i++) { isprime[i]=true; } for(int i=2;i<MAXN;i++) { if(isp

weixin_43801993的博客 135

PAT 甲级 1058 A+B in Hogwarts [Java实现]

1. 题意 也是进制转换的题目 两个数字相加,然后第二项是17进制,第三项是29进制 2. 思路 水题。 注意最高位没有进位限制,一开始被这个坑了。 3. 代码 package adv1058; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** *...

zmjのblog 190

PAT 甲级 1059  Prime Factors

1059 Prime Factors (25 point(s)) Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​. Input ...

漫浸天空的雨色的备忘录~ 782

PAT_甲级_1058

1058 A+B in Hogwarts If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twent...

lzc842650834的博客 231

PAT甲级1059 Prime Factors

1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​. Input Specifi...

小康的博客 326
上一篇: PAT甲级1056,1057解题报告
下一篇: PAT甲级1060,1061解题报告
Tate_Brown
博客等级 码龄9年 39粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址