集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里。比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸。 本题给定一张不相容物品的清单,需要你检查每一张集装箱货品清单,判断它们是否能装在同一只箱子里。 输入格式: 输入第一行给出两个正整数:N (≤10​4​​) 是成对的不相容物品的对数;M (≤100) 是集装箱货品清单的单数。 随后数据分两大块给出。第一块有 N 行,每行给出一对不相容的物品。第二块有 M 行,每行给出一箱货物的清单,格式如下: K G[1] G[2] … G[K] 其中K(≤1000) 是物品件数,G[i]是物品的编号。简单起见,每件物品用一个
Read more »

子曰:“三人行,必有我师焉。择其善者而从之,其不善者而改之。” 本题给定甲、乙、丙三个人的能力值关系为:甲的能力值确定是 2 位正整数;把甲的能力值的 2 个数字调换位置就是乙的能力值;甲乙两人能力差是丙的能力值的 X 倍;乙的能力值是丙的 Y 倍。请你指出谁比你强应“从之”,谁比你弱应“改之”。 输入格式: 输入在一行中给出三个数,依次为:M(你自己的能力值)、X 和 Y。三个数字均为不超过 1000 的正整数。 输出格式: 在一行中首先输出甲的能力值,随后依次输出甲、乙、丙三人与你的关系:如果其比你强,输出Cong;平等则输出Ping;比你弱则输出Gai。其间以 1 个空格分隔,行首尾
Read more »

当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x的最大自然数,即 x 的整数部分。) 输入格式: 输入给出一个正整数 N(2≤N≤10​4​​)。 输出格式: 在一行中输出题面中算式取到的不同值的个数。 输入样例: 2017 输出样例: 1480 一层for循环i从1到n,把i/2 + i/3 + i/n的值插入到set中,输出set的size就是不同值的个数。 1 2 3 4 5 6 7 8 9 10 11 12 13 #include #include
Read more »

做作业的时候,邻座的小盆友问你:“五乘以七等于多少?”你应该不失礼貌地围笑着告诉他:“五十三。”本题就要求你,对任何一对给定的正整数,倒着输出它们的乘积。 输入格式: 输入在第一行给出两个不超过 1000 的正整数 A 和 B,其间以空格分隔。 输出格式: 在一行中倒着输出 A 和 B 的乘积。 输入样例: 5 7 输出样例: 53 偷懒的用库函数去AC了。 a 和 b的乘积转换成字符串,然后将字符串翻转,最后将翻转过的字符串转换成数字就是答案。 PS: 图片是电影《放牛班的春天》的截图。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include
Read more »

第 11 章 多线程 * 简述线程的基本概念,程序、进程、线程的关系是什么。 线程与进程相似,但线程是一个比进程更小的执行单位。 程序是静态的代码,进程是程序的一次执行过程,是系统运行程序的基本单位;线程是进程的更小的划分 * 什么是多线程?为什么程序的多线程功能是必要的? 多线程就是同事执行一个以上的线程,一个线程的执行不必等待另一个线程执行完后才执行,所有线程都可以发生在同一时刻;单一的进程在执行任务会出现资源空闲,采用多线程可以让CPU在同一个时间之内执行一个程序中得好几个程序段来完成工作 * 多线程与多任务的差异是什么? 多任务是针对操作系统而言的 ,表示操作系统可以同事运行多个
Read more »

A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range. Now given the map of the city and several candidate locations for the
Read more »

Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case, the first line contains two integers N (≤10​5​​) and C, where N is the number of records and C is the column that you are suppos
Read more »

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 forRed, the middle 2 digits forGreen, and the last 2 digits forBlue. The only difference is that they use radix 13 (0-9 and A
Read more »

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge a
Read more »

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a different permutation. Check to see the result if
Read more »
0%