factorial（数论，简单模拟）
In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.
输入格式
Input consists of several lines of integer numbers. The first line contains an integer T, which is the number of cases to be tested, followed by T lines, one integer 1 ≤ n ≤ 10000000 on each line.
1≤T≤10
输出格式
The output contains the number of digits in the factorial of the integers appearing in the input.
输入样例
1  2 
输出样例
1  7 
题目大意
求N的阶乘的位数。看一下题目给的数据范围，不可能求出阶乘的结果再取对数的。那么就直接取对数。因为阶乘就是乘积，所以在对数运算下会直接变成加法。那么答案就显而易见。
题解
1 

exam（排序算法，模拟）
The final exam is over. In order to give rewards, the teacher should rank the students in the class.
There are N students in the class. This semester, they have learned K courses.
The student number of the ith student is Xi, and his score of the jth course is expressed as Aij.
The ranking rules are as follows:
If the scores of two students are different, the first course with different scores will be the basis for ranking, and the one with higher scores will come first.
If the scores of the two students are identical, the one with the smaller student number will come first.
输入格式
The first line contains N, K (N≤1000,K≤10).
In the following N lines, the ith line contains K+1 integers X**i Ai*1 *Ai2 Ai3 … Ai**k. (X**i<100000,Aij<100000)
Guarantee student number is different.
输出格式
A line contains n integers, which are the student numbers from the first to the last, separated by spaces.
There should be a space after the last number
输入样例
1  4 3 
输出样例
1  4 3 2 1 
题目大意
按照给定规则给所有的学生成绩排序。规则是按照两个学生第一个不相同的学科成绩排序，大的在前。如果完全相同就按照学号大小升序排序。
实际上就是改变sort的cmp函数。由于这题使用结构体定义学生的，所以可以直接在结构体内重载小于运算符。
1 

stack（超级水题，模拟）
Xiaoming is learning stack. Stack is a last in, first out data structure. There are only two operations: adding an element to the end of the stack and taking out the end element. Now Xiaoming asks you to help him simulate the operation of the stack.
输入格式
The first line contains an integer n indicating how many operations there are. (N≤100000)
Next N lines, two integers A and B per line. A = 1 means to add B to the tail of the stack, A = 2 means to take out the tail element of B times. (B<100000)
The stack is initially empty. Ensure that elements are not removed from the empty stack.
输出格式
The first line, an integer m, indicates how many elements are left in the stack.
The second line, m integers, lists the m elements from the beginning to the end of the stack, separated by spaces.
输入样例
1  5 
输出样例
1  3 
题目大意
没什么好说的。stack<int>
秒过。注意最后要再倒一下输出。我的方法是再开一个栈就行。
题解
1 

Hateful Fat（数论，计算几何）
LCY lost his pen when he was studying, which is really a bad situation, because his eyes have been blocked by his fat. So can you tell him the positional relationship between him and the pencil?
For given three points p0,p1,p2,
print “ COUNTER_CLOCKWISE” if p0,p1,p2 make a counterclockwise turn (1)
print “ CLOCKWISE” if p0,p1,p2 make a clockwise turn (2),
print “ ONLINE_BACK” if p2 is on a line p2,p0,p1 in this order (3),
print “ ONLINE_FRONT “if p2 is on a line p0,p1,p2 in this order (4),
print “ ON_SEGMENT” if p2 is on a segment p0p1(5).
Input:
In the first line, integer coordinates of p0 and p1 are given.
The next line gives an integer q, which represents the number of queries.
Then, q queries are given for integer coordinates of p2.
Output:
For each query, print the above mentioned status.
Sample Input:
1  0 0 2 0 
Sample Output:
1  COUNTER_CLOCKWISE 
题目大意
给出P0P1和P0P2两条直线，求在直角坐标系中两条直线的位置关系。计算即可。过程看代码。就是写着写着容易乱……
题解
1 

prime（数论，素数筛）
Xiaoming is learning prime number, which is a integer greater than 1 and can only be divided by 1 and itself. Xiao Ming has learned how to judge whether a number is prime. Now, he wants to know how many prime numbers are in [1, N].
输入格式
An integer N.(N<=10000000)
输出格式
An integer represents how many prime numbers are in [1, N].
输入样例
1  10 
输出样例
1  4 
题目大意
求[1,N]之间的素数个数。看数据范围肯定不能直接求，不然这题还有什么意思……埃氏筛不知道能过嘛（估计能），我用的欧拉筛，稳定输出。
题解
1 

lcy‘s weight（高精度）
During the holiday, LCY has been eating snacks, but sometimes he also exercises, so his weight has been changing. At the same time, LCY is an excellent college student, so he records the change of his weight the day before every day. But n days later, he found that he could not know how heavy he was now, but he could remember his weight on the first day as M. So LCY found smart you. I hope you can help him calculate his weight now, so can you help him?
Input
The first line gives two integers, N and M, representing the days lcy experienced and the weight of the first day.(n≤104,m≤1010000)
Then n lines followed.
Each line contains two integers x and y.(y≤1010000)
When x equals 1, it means that LCY’s current weight is y heavier than the previous day.
When x equals 2, it means that LCY’s current weight is y lighter than the previous day.
When x equals 3, it means that LCY’s current weight is y times heavier than the previous day.
Ensure LCY’s weight is always less than 1010000
Output
Output a single line represents the weight after n days of LCY
Input Sample
1  4 70 
Output Sample
1  6300000000000 
题目大意
高精度加法减法和乘法，不会用java，用不了python，简直噩梦。来个模板，注意，用string会t掉。
题解
1 

附上java的大整数代码（总体来说要比c++快那么一点点）
1  import java.util.*; 
Prepare for CET6（字符串，字典树Trie）
In order to prepare the CET6 exam, LCY is reciting English words recently. Because he is already very clever, he can only recite n words to get full marks. He is going to memorize K words every day. But he found that if the length of the longest prefix shared by all the strings in that day is a**i, then he could get a**i laziness value. The lazy LCY must hope that the lazier the better, so what is the maximum laziness value he can get?
For example:
The group {RAINBOW, RANK, RANDOM, RANK} has a laziness value of 2 (the longest prefix is ‘RA’).
The group {FIRE, FIREBALL, FIREFIGHTER} has a laziness value of 4 (the longest prefix is ‘FIRE’).
The group {ALLOCATION, PLATE, WORKOUT, BUNDLING} has a laziness value of 0 (the longest prefix is ‘’).
Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the two integers N and K. Then, N lines follow, each containing one of Pip’s strings.
2≤N≤105
2≤K≤N
Each of Pip’s strings contain at least one character.
Each string consists only of letters from A to Z.
K divides N.
The total number of characters in Pip’s strings across all test cases is at most .
Output
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the maximum sum of scores possible.
Input sample
1  2 
Output Sample
1  Case #1: 0 
题目大意
先用字典树求各节点的前缀数目，然后求对K的贡献和即可。
题解
1 

Computer Games（博弈论）
LCY is playing games with his computer at home. Each playing card has two attributes: A**i and B**i, LCY and his computer take turns selecting playing cards,with LCY going first. In each turn, a player can select one card, as long as that playing card either has an A**i greater than each of the all soldiers selected so far, or has a B**i greater than each of the all cards selected so far.
To be precise:
let A**i and B**i be the values for the ith cards, for i from 1 to N, and let S be the set of cards that have been selected so far. Then a player can select card x if and only if at least one of the following is true:
A**x>A*sfor all *s in S
B**x>B**s for all s in S
If no selection can be made, then the selection process ends and the player with more playing cards win. LCY wants to select more cards and win the game. If both players play optimally to accomplish their goals, can LCY succeed?
输入格式
The first line of each case contains a positive integer N, the number of cards. N more lines follow; the ith of these line contains two integers Ai and Bi, indicating the values of the ith cards.(N≤4000,0≤A**i,B*i*≤10000)
输出格式
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is YES or NO, indicating whether LCY can guarantee that he selects more cards than computer, even if computer plays optimally to prevent this.
Input Sample
1  3 
Output Sample
1  Case #1: NO 
题目大意
1、玩家先手，所以只要保证到电脑拿牌的时候无法再拿的时候就一定赢；
2、无法再拿的条件：当前牌堆中的排的两面都不存在比已拿牌堆中更大的牌；
3、对AI和BI排序，如果存在同一张牌的正反面的次序相同，就一定能赢。
题解
1 

sort（签到题，排序）
Xiaoming is tired of asking for help. This time he wants to test you.
He gave you N integers. Please find the number with the largest M.
输入格式
The first row has two numbers N, M (0<m≤n≤1000000).
The second line contains N integers that are different and are all in the interval [ 500000,500000].
输出格式
Output the number of the first M in the order of large to small.
输入样例
1  5 3 
输出样例
1  213 92 3 
题目大意
降序排序，输出前M个数
题解
1 

lcy eats biscuits（图的遍历，搜索回溯剪枝）
In order to grow nine abdominal muscles, LCY began to eat all the N biscuits in his room, but LCY didn’t like walking, because walking would cause his abdominal muscles to become smaller.How long does he have to run to get n biscuits. At the beginning, LCY is at (0,0)
Input
The first line is a positive integer N.(N≤14)
Next, there are 2 real numbers in each line, representing the coordinates of the ith biscuits.(−10000≤x**i,y*i*≤10000)
The distance formula between two points is√(x1−x2)2+(y1−y2)2
Output
A number, representing the minimum distance to run, with 2 decimal places reserved.
Input Sample
1  4 
Output Sample
1  7.41 
题目大意
从0开始，走完全部的点需要的最少时间。其中距离按照两点之间的距离来算。
暴力搜索是对的。但是要注意两个条件：
1、对于这种两两之间都是可走的就无需建图，直接算会方便的多。
2、注意递归结束条件，根据开始条件的不同而不同。
3、当前的距离已经比之前最小距离大的时候，无需进行下一步运算。（剪枝）
题解
1 
