Pat(A) 1108. Finding Average (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1108

1108. Finding Average (20)


The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A "legal" input is a real number in [-1000, 1000] and is accurate up to no more than 2 decimal places. When you calculate the average, those illegal numbers must not be counted in.

继续阅读


Pat(A) 1107. Social Clusters (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1107

1107. Social Clusters (30)


When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of their hobbies in common. You are supposed to find all the clusters.

Input Specification:

继续阅读


Pat(A) 1106. Lowest Price in Supply Chain (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1106

1106. Lowest Price in Supply Chain (25)


A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.

Starting from one root supplier, everyone on the chain buys products from one's supplier in a price P and sell or distribute them in a price that is r%

继续阅读


Pat(A) 1105. Spiral Matrix (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1105

1105. Spiral Matrix (25)


This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in a clockwise spiral. The matrix has m rows and n columns, where m and n satisfy the following: m*n must be equal to N; m>=n; and m-n is the minimum of all the possible values.

继续阅读


Pat(A) 1104. Sum of Number Segments (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1104

1104. Sum of Number Segments (20)


Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) (0.4).

继续阅读


Pat(A) 1103. Integer Factorization (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1103

1103. Integer Factorization (30)


The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P factorization of N for any positive integers N, K and P.

Input Specification:

继续阅读


C++全局变量值被修改

2017年9月9日晚,在做PAT甲级1103 Integer Factorization (30)一题时碰到一个问题,测试点5总是过不去。后来经过10号晚上反复测试发现其中一个全局变量的值在执行某个函数是被莫名修改了。

为验证全局变量的改动情况,写了一部分代码用于测试,如下:

#include "iostream"
using namespace std;

int factor[20 + 1];
int sumOfAns = 0;

int main(){
    int i = 1;
    factor[1] = 1;
    while(i <= 20){
        i ++;
        factor[i] = 1234;
    }
    //sumOfAns = 0;
    cout<<sumOfAns<<endl;
    system("pause");
}

执行结果为:

1234

很明显是已经被改动了。 然而倘若将第5行代码

继续阅读


Pat(A) 1102. Invert a Binary Tree (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1102

1102. Invert a Binary Tree (25)


The following is from Max Howell @twitter:

Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.

Now it's your turn to prove that YOU CAN invert a binary tree!

Input Specification:

继续阅读


Pat(A) 1100. Mars Numbers (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1100

1100. Mars Numbers (20)


People on Mars count their numbers with base 13:

Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Mars, respectively. For the next higher digit, Mars people name the 12 numbers as "tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou", respectively.

继续阅读


Pat(A) 1101. Quick Sort (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1101

1101. Quick Sort (25)


There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its left and those larger than the pivot to its right. Given N distinct positive integers after a

继续阅读


Pat(A) 1095. Cars on Campus (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1095

1095. Cars on Campus (30)


Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at any specific time point, the number of cars parking on campus, and at the end of the day find the cars that have parked for the longest time period.

继续阅读


Pat(A) 1094. The Largest Generation (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1094

1094. The Largest Generation (25)


A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.

Input Specification:

Each input file contains one test case. Each case starts

继续阅读


Pat(A) 1093. Count PAT's (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1093

1093. Count PAT's (25)


The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.

Now given any string, you are supposed to tell the number of PAT's contained in the string.

Input Specification:

继续阅读


Pat(A) 1092. To Buy or Not to Buy (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1092

1092. To Buy or Not to Buy (20)


Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in whole pieces. Hence Eva must check whether a string in

继续阅读


Pat(A) 1091. Acute Stroke (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1091

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 stroke core.

Input Specification:

继续阅读


Pat(A) 1090. Highest Price in Supply Chain (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1090

1090. Highest Price in Supply Chain (25)


A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.

继续阅读


Pat(A) 1089. Insert or Merge (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1089

1089. Insert or Merge (25)


According to Wikipedia:

Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there. It repeats until no input elements remain.

继续阅读


Pat(A) 1088. Rational Arithmetic (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1088

1088. Rational Arithmetic (20)


For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.

Input Specification:

Each input file contains one test case, which gives in one line the two rational numbers in the format "a1/b1 a2/b2".

继续阅读


Pat(A) 1087. All Roads Lead to Rome (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1087

1087. All Roads Lead to Rome (30)


Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.

Each input file contains one test case. For each case, the first line contains 2 positive integers N (2<=N<=200), the number of cities, and K, the total number of routes betwee

继续阅读


Powered by Django 2. Copyright © 2014.

huchengbei.com. All rights reserved.