| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1157 人关注过本帖
标题:第31届ICPC北京赛区网络试题(E,F)
取消只看楼主 加入收藏
蓝色神话
Rank: 2
等 级:论坛游民
威 望:1
帖 子:404
专家分:24
注 册:2006-5-11
收藏
 问题点数:0 回复次数:0 
第31届ICPC北京赛区网络试题(E,F)

Find the largest LCM(E)
Time Limit:4S Memory Limit:5120K
Description
I believe that most of you know how to split a positive integer N into the sum of several positive integers, such that their product is the biggest. We only shall try best to split N into the sum of multiple 3.
Then, how about splitting N such that their Least Common Multiplier (LCM) is the biggest?
Input
Input contains several test cases.
Each case has only one line, consisting of two positive integers, N and M. (0 < N <= 3000, 0 < M <= 10000)
The last case is followed by a line containing two zeros.
Output
The output for each case contains the biggest LCM's mod M.
Sample Input
6 23
6 23
0 0
Sample Output
Case 1: 6
Case 2: 6

Strange Machine(F)
Time Limit:10S Memory Limit:32768K
Description
One Day, you find the neighbor girl gets a magic machine! When pressing the green button, the two bulbs above will flash by turns; when pressing the red buttons, the machine will make a precise movement forward. What excites the girl most is that the machine can quickly calculate how many pairs of poker cards are not put in such order that the bigger number is under the smaller one. So, when you put some down cards with number on each card before the machine, and press the green and red buttons at the same time, it will quickly run ahead and write down exactly how many pairs of cards are in wrong order! You ask the girl how she gets this machine. She always says that a smiling handsome guy with green hair gives her the gift in her dream, and she wakes up with the machine in her hands.
You are unwilling to show weakness and claim that such number, called 'inversion pair', is easy to calculate, and there is a whole set of algorithms, such as merging algorithm, to deal with such problems. However, when the girl tells you that the machine's result will change quickly and exactly as soon as you switch the order of the two cards, you blush and promise her for a simulation program...Now is the time for you to keep your promise.
Input
Input contains several cases.
For each case, the first line contains two numbers, specifying that there are n poker cards and m times of switch(1 <= n <= 10^5, 1 <= m <= 10^5). The second line contains n numbers, specifying the number in each poker card from up to down. The number ranges from 0 to 100,000. There are m lines followed, each line contains 2 numbers, specifying the rank number of the two switch cards from up to down.
Input ends with a zero.
Output
For each case, you should first output how many inversion pairs in the initial pile of poker cards, then output the number of inversion pairs after each switch.
Sample Input
2 1
1 2
1 2
10 5
2 5 8 7 6 1 9 4 10 3
1 6
3 9
2 10
4 5
8 6
0
Sample Output
Case 1:
0
1
Case 2:
20
19
22
19
18
19

搜索更多相关主题的帖子: 北京 网络 赛区 试题 ICPC 
2006-10-11 12:02
快速回复:第31届ICPC北京赛区网络试题(E,F)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018036 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved