PAT乙级:1083 是否存在相等的差 (20分) 题干 给定 N 张卡片,正面分别写上 1.2.--.N,然后全部翻面,洗牌,在背面分别写上 1.2.--.N.将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差? 输入格式: 输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字. 输出格式: 按照"差值 重复次数"的格式从大到小输出重复的差值及其重复…
1083 是否存在相等的差(20 分) 给定 N 张卡片,正面分别写上 1.2.…….N,然后全部翻面,洗牌,在背面分别写上 1.2.…….N.将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差? 输入格式: 输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字. 输出格式: 按照“差值 重复次数”的格式从大到小输出重复的差值及其重复的次数,每行输出一个结果.…
题目 给定 N 张卡⽚,正⾯分别写上 1.2.--.N,然后全部翻⾯,洗牌,在背⾯分别写上 1.2.--. N.将每张牌的正反两⾯数字相减(⼤减⼩),得到 N 个⾮负差值,其中是否存在相等的差? 输⼊格式: 输⼊第⼀⾏给出⼀个正整数 N(2 <= N <= 10000),随后⼀⾏给出 1 到 N 的⼀个洗牌后的排列,第 i 个数表示正⾯写了 i 的那张卡⽚背⾯的数字. 输出格式: 按照"差值 重复次数"的格式从⼤到⼩输出重复的差值及其重复的次数,每⾏输出⼀个结果. 输⼊样例…
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for R…
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit…
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup tro…
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 的每位数的和,并且用英语输出和的每一位数…
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 译:计算 a + b 的和,并格式化…
PAT甲级:1124 Raffle for Weibo Followers (20分) 题干 John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give aw…
//这题不是我耍流氓,实在太简单,只能直接贴代码了,凑个数 #include<stdio.h> int aaa[10005]={0}; int main(){ int N;scanf("%d",&N);//卡片数 for(int i=1;i<=N;i++){//循环输入数据,一面为下标,一面为元素内容 int temp; scanf("%d",&temp); int a=abs(temp-i); aaa[a]++; } for(in…
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main(){ int nG,nS,nK,payG,payS,payK; scanf("%d.%d.%d %d.%d.%d",&nG,&nS,&nK,&payG,&payS,&payK); if(payK>=nK){ payK-=nK;…
1065 A+B and C (64bit)(20 分) Given three integers A, B and C in [−263,263], you are supposed to tell whether A+B>C. Input Specification: The first line of the input gives the positive number of test cases, T (≤10). Then T test cases follow, eac…