【PAT】1041. Be Unique (20)】的更多相关文章

题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1041 题目描述: Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one…
1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen fr…
1041 Be Unique (20 分)   Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1]. The first one who bets on a unique number wins. For examp…
题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 第一次出现的数字 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdlib> #include <cmath> #include <climit…
题意: 输入一个正整数N(<=1e5),接下来输入N个正整数.输出第一个独特的数(N个数中没有第二个和他相等的),如果没有这样的数就输出"None". AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; multiset<int>st; ]; int main(){ ios::sync_with_stdio(false);…
1004. 成绩排名 (20) 读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. 输入格式:每个测试输入包含1个测试用例,格式为 第1行:正整数n 第2行:第1个学生的姓名 学号 成绩 第3行:第2个学生的姓名 学号 成绩 ... ... ... 第n+1行:第n个学生的姓名 学号 成绩 其中姓名和学号均为不超过10个字符的字符串,成绩为0到100之间的一个整数,这里保证在一组测试用例中没有两个学生的成绩是相同的. 输出格式:对每个测试用例输出2行,第1行是成绩最高学…
1019 数字黑洞 (20)(20 分) 给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字.一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫Kaprekar常数. 例如,我们从6767开始,将得到 7766 - 6677 = 1089\ 9810 - 0189 = 9621\ 9621 - 1269 = 8352\ 8532 - 2358 = 6174\ 7641 - 146…
1013. 数素数 (20) 令Pi表示第i个素数.现任给两个正整数M <= N <= 104,请输出PM到PN的所有素数. 输入格式: 输入在一行中给出M和N,其间以空格分隔. 输出格式: 输出从PM到PN的所有素数,每10个数字占1行,其间以空格分隔,但行末不得有多余空格. 输入样例: 5 27 输出样例: 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 程序说明: 定义一个布尔型的素数判别函数,…
1012. 数字分类 (20) 给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所有偶数的和: A2 = 将被5除后余1的数字按给出顺序进行交错求和,即计算n1-n2+n3-n4...: A3 = 被5除后余2的数字的个数: A4 = 被5除后余3的数字的平均数,精确到小数点后1位: A5 = 被5除后余4的数字中最大数字. 输入格式: 每个输入包含1个测试用例.每个测试用例先给出一个不超过1000的正整数N,随后给出N个不超过1000的待分类的正整数…
1009. 说反话 (20) 给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出. 输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串.字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用1个空格分开,输入保证句子末尾没有多余的空格. 输出格式:每个测试用例的输出占一行,输出倒序后的句子. 输入样例: Hello World Here I Come 输出样例: Come I Here World Hello 方法一:程序说明:…
1007. 素数对猜想 (20) 让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数.显然有 d1=1 且对于n>1有 dn 是偶数.“素数对猜想”认为“存在无穷多对相邻且差为2的素数”. 现给定任意正整数N (< 105),请计算不超过N的满足猜想的素数对的个数. 输入格式:每个测试输入包含1个测试用例,给出正整数N. 输出格式:每个测试用例的输出占一行,不超过N的满足猜想的素数对的个数. 输入样例: 20 输出样例: 4 关于素数判断函数: 第1种:按照定义进行判…
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1]. The first one who bets on a unique number wins. For example, if there are 7 peopl…
题目 Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 10^4]. The first one who bets on a unique number wins. For example, if there ar…
这道题的逻辑怪复杂的,写起来蛮费时间的 结构体中要储存的信息多,整体不难,信息量大,容易把人搞蒙 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct ti{ int tihao; int fen; int xuan; int Tnum; bool zhengquedaan[127]={0}; int cuo=0; }Data[101]; bool cmp…
如果了解分数运算,本题很简单.我有对分数知识进行总结 分数四则运算 #include<stdio.h> #include<algorithm> using namespace std; int gongyue(int a,int b){ return !b?a:gongyue(b,a%b); } struct fenshu{ int fenzi; int fenmu; }shu1,shu2,shu3; bool fenshujudge(struct fenshu A,struct…
以前写的,逻辑不好,过后再改 #include<stdio.h> #include<algorithm> #include<math.h> using namespace std; bool cmp(int a,int b){ return a<b; } int zhenghao(int a){ return a%10+a%100/10+a%1000/100+a/1000; } bool youmeiyou(int *arr,int a,int flag){ in…
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10 4 ]. The first…
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10​4​​]. The first one who bets on a unique number wins. For…
OpenStack Kilo版本发布 20英文文档OpenStack Kilo版本文档汇总:各个操作系统安装部署.配置文档.用户指南等文档 Kilo版部署 openstack[Kilo]入门 [准备篇]零:整体介绍 openstack[Kilo]入门 [准备篇]一: Ubuntu14.04远程连接(ssh安装) openstack[Kilo]入门 [准备篇]二:NTP安装 openstack[Kilo]入门 [准备篇]三:mysql(MariaDB)安装[控制节点] openstack[Kilo…
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 请实现一个函数用来判断字符串是否表示数值(包括整数和小数).例如,字符串“+100”.“5e2”.“-123”.“3.1416”及“-1E-16”都表示数值,但“12e”.“1a3.14”.“1.2.3”.“+-5”及“12e+5.4”都不是. 思路 刚开始的思路是从头到尾遍历,对遇到的不同情况进行分析,但很容易出错.因此采用<剑指OFFER>一书的方法:将数字…
这道题算有点难,心目中理想的难度. 不能前怕狼后怕虎,一会担心超时,一会又担心内存过大,直接撸 将三部分分别保存到vector 有意思的在于输出 分别输出第一个的add和num 中间输出nextadd ,换行,add,num 最后输出尾元素的next为-1 #include<iostream> #include<stdio.h> #include<map> #include<string> #include<algorithm> #include…
1091 Acute Stroke(30 分) One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the…
Difficulty:easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/first-unique-character-in-a-string/ Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s =…
1041 Be Unique Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10​4​​]. The first one who bets on a unique number wins. For example…
1003. 我要通过!(20) “答案正确”是自动判题系统给出的最令人欢喜的回复.本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”. 得到“答案正确”的条件是: 1. 字符串中必须仅有P, A, T这三种字符,不可以包含其它字符:2. 任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串:3. 如果 aPbTc 是正确的,那么 aPbATca 也是正确的,其中 a, b…
1002. 写出这个数 (20) 读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式:每个测试输入包含1个测试用例,即给出自然数n的值.这里保证n小于10100. 输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格. 输入样例: 1234567890987654321123456789 输出样例: yi san wu C 代码如下: #include <stdio.h> #include <stdlib.h…
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: 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…
/* 火星文有两位,第二位为0不输出 */ #include<stdio.h> #include<algorithm> #include<string.h> #include<ctype.h> using namespace std; char arr[20]={0}; char data[13][2][5]={ {"tret","tret"}, {"jan","tam"}, {…
一开始因为看见这题就头疼,可费了点时间. 要考虑所有元素,如果忽略外圈元素,最后一个样例过不去. 而且要求只出现一次的元素, 我没有使用map,因为当时还没学,用map储存元素会节约好多代码 #include<cstdio> #include<string.h> int M,N,TOL; int arr[1001][1001]; int da[20000000]={0}; int dir[8][2] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1…
此处为我的存储结构,只提供一种思路,二维数组存储所有数据 #include<stdio.h> #include<string.h> #include<map> #include<vector> #include<algorithm> using namespace std; int ti[200][20]={0}; bool ffind(char *p,char c){ int len = strlen(p); for(int i=0;i<…