上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们可以使用字符串输入,之后分别遍历每一位,将其分别存入sum中. 因为是从高到低输出每一位,而不是从低到高:若是后者,则可以使用一个小函数不断取余再除以10即可全部输出:此时是前者,则可使用sstream头文件,将sum转换为字符串形式,再分别遍历每一位,输出每一位的值对应的字符数组分量,即可AC.…
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤). Ou…
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. 译:给出一个非负整数 N , 你的任务是计算出 N 的每位数的和,并且用英语输出和的每一位数…
1005 Spell It Right (20分) 题目: Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one li…
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one l…
1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: E…
题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 = 10000 所以 sum 用int 保存就好了 再把 sum 的每一位 用 英文输出 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdlib> #incl…
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤). Ou…
题意: 给出一个非零整数N(<=10^100),计算每位之和并用英文输出. AAAAAccepted code: #include<bits/stdc++.h> using namespace std; string s; ][]={"zero","one","two","three","four","five","six","seven&…
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤). Ou…
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one l…
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (o…
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order.…
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found…
PAT乙级:1072开学寄语(20分) 题干 下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面.理发.整衣,然后思过.读书.锻炼.明智.开悟.精进.而后必成大器也! 本题要求你写个程序帮助这所学校的老师检查所有学生的物品,以助其成大器. 输入格式: 输入第一行给出两个正整数 N(≤ 1000)和 M(≤ 6),分别是学生人数和需要被查缴的物品种类数.第二行给出 M 个需要被查缴的物品编号,其…
PAT乙级:1057 数零壹 (20分) 题干 给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一下 N 的二进制表示中有多少 0.多少 1.例如给定字符串 PAT (Basic),其字母序号之和为:16+1+20+2+1+19+9+3=71,而 71 的二进制是 1000111,即有 3 个 0.4 个 1. 输入格式: 输入在一行中给出长度不超过 105.以回车结束的字符串. 输出格式: 在…
PAT乙级:1082 射击比赛 (20分) 题干 本题目给出的射击比赛的规则非常简单,谁打的弹洞距离靶心最近,谁就是冠军:谁差得最远,谁就是菜鸟.本题给出一系列弹洞的平面坐标(x,y),请你编写程序找出冠军和菜鸟.我们假设靶心在原点(0,0). 输入格式: 输入在第一行中给出一个正整数 N(≤ 10 000).随后 N 行,每行按下列格式给出: ID x y 其中 ID 是运动员的编号(由 4 位数字组成):x 和 y 是其打出的弹洞的平面坐标(x,y),均为整数,且 0 ≤ |x|, |y|…
PAT乙级:1084 外观数列 (20分) 题干 外观数列是指具有以下特点的整数序列: d, d1, d111, d113, d11231, d112213111, ... 它从不等于 1 的数字 d 开始,序列的第 n+1 项是对第 n 项的描述.比如第 2 项表示第 1 项有 1 个 d,所以就是 d1:第 2 项是 1 个 d(对应 d1)和 1 个 1(对应 11),所以第 3 项就是 d111.又比如第 4 项是 d113,其描述就是 1 个 d,2 个 1,1 个 3,所以下一项就是…
PAT乙级:1063 计算谱半径 (20分) 题干 在数学中,矩阵的"谱半径"是指其特征值的模集合的上确界.换言之,对于给定的 n 个复数空间的特征值 { a1+b1i,⋯,a**n+bni },它们的模为实部与虚部的平方和的开方,而"谱半径"就是最大模. 现在给定一些复数空间的特征值,请你计算并输出这些特征值的谱半径. 输入格式: 输入第一行给出正整数 N(≤ 10 000)是输入的特征值的个数.随后 N 行,每行给出 1 个特征值的实部和虚部,其间以空格分隔.注…
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line…
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line…
1005 Programming Pattern (35 分) Programmers often have a preference among program constructs. For example, some may prefer if(0==a), while others may prefer if(!a). Analyzing such patterns can help to narrow down a programmer's identity, which is use…
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<vector> using namespace std; +; char s[maxn]; int tmp[maxn],tot; ][]={ "zero", "one", "two…
把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; /* 把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 水 */ ][]={"zero","one&…
https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336 Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file c…
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (<= 101…
problem Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N…
/* 15分的题很简单,但是自己写的时候在输入数据时没有考虑好下标 另外有忘记了输入字符时考虑是否有\n */ #include<stdio.h> #include<algorithm> #include<string.h> #include<ctype.h> using namespace std; int main(){ char str[1005]; int arr[26]={0}; scanf("%[^\n]",str); int…
地球人习惯使用十进制数,并且默认一个数字的每一位都是十进制的.而在 PAT 星人开挂的世界里,每个数字的每一位都是不同进制的,这种神奇的数字称为“PAT数”.每个 PAT 星人都必须熟记各位数字的进制表,例如“……0527”就表示最低位是 7 进制数.第 2 位是 2 进制数.第 3 位是 5 进制数.第 4 位是 10 进制数,等等.每一位的进制 d 或者是 0(表示十进制).或者是 [2,9] 区间内的整数.理论上这个进制表应该包含无穷多位数字,但从实际应用出发,PAT 星人通常只需要记住前…
题目链接:1085 PAT单位排行 (25 point(s)) 题目描述 每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜.本题就请你实现这个功能. 输入格式 输入第一行给出一个正整数 N(≤10​5​​),即考生人数.随后 N 行,每行按下列格式给出一个考生的信息: 准考证号 得分 学校 其中准考证号是由 6 个字符组成的字符串,其首字母表示考试的级别:B代表乙级,A代表甲级,T代表顶级:得分是 [0, 100] 区间内的整数:学校是由不超过 6 个英文字母组成的单位码(大小写无关…