java 程序 young gc 次数频繁,怎么调试

有两台服务器,配置相差不大,运行的代码一样,java的配置的也一样,分配的留啦也一样,但是通过jstat -gc pid 看到的gc次数差别很大,像这样频繁的young gc ,该怎么调试?

192.168.1.138 | CHANGED | rc=0 >>
109837, 运行时间 02:39:30
109837, full  gc次数 6         平均时间 0.869
109837, young gc次数 1235      平均时间 0.087


192.168.1.139 | CHANGED | rc=0 >>
151208, 运行时间 02:46:08
151208, full  gc次数 22        平均时间 0.213
151208, young gc次数 10117     平均时间 0.057

3个回答

可以看下你的服务器的 JVM 配置的是什么模式,一般用 -server 模式比较好。

JAVA_OPTS="$JAVA_OPTS -server -Xms512m -Xmx2048m -XX:PermSize=512M -XX:MaxPermSize=512m

增加内存,扩大初始化内存

先确定下两台服务器这个服务的访问量是不是一样,如果第二台访问过多,同事初始内存较小的话,可能会发生这种频繁GC。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Java系统中GC频繁启动是什么原因?
我这两天在面试一个工作,他们好像遇到问题,可能现在的系统代码质量不高,GC每3 秒钟启动一次,他问我是不是修改JVM的参数可以解决,调正GC的young、old、 permanent的大小?我过两天要去面试,想准备一下,有人知道这是为什么吗?有什么 解决的途径?
young GC 对于机器的性能影响多大?
如果系统大量new对象,那么应该会导致young GC的频率加大, 如果youngGC的平率加大,那么具体对于机器的影响是什么?CPU的消耗? qps,rt会有什么现象
jvm young gc 时间突然增加,一般怎么着手分析啊?跪求指导~~
代码无改动,有一台机器ygc time 突然变长,然后又恢复了。 不知哪位大神可以指导下,应该如何进行分析啊?需要考虑哪些情况会引起这种问题呢? ![gc log](https://img-ask.csdn.net/upload/201803/12/1520845002_35479.png) jvm 参数配置如下: -Xloggc:/var/logs/gc.log.201803072057 -XX:ErrorFile=/var/logs/vmerr.log.201803072057 -Xmx4g -Xms4g -XX:SurvivorRatio=8 -XX:NewRatio=3 -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintCommandLineFlags -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelCMSThreads=8 -XX:+CMSClassUnloadingEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=1 -XX:CMSInitiatingOccupancyFraction=50 -XX:+UseCMSInitiatingOccupancyOnly -XX:HeapDumpPath=/var/logs/heaperr.log.201803072057
Young 怎么用程序来实现的
Description Consider m natural numbers n1, n2, ..., nm with the property n1 >= n2 >= ... >= nm > 0. We define a Young table as an arrangement in a table of n1 + n2 + ... + nm natural numbers (bigger than 0 and any two different), so that the ith line has ni elements (1 <= i <= m) in ascending order from left to right, and the elements from the same column are in ascending order from bottom to top. An example of Young table for m = 4, n1 = 6, n2 = 4, n3 = 4, n4 = 1 is the following: 1 2 5 9 10 15 3 6 7 13 4 8 12 14 11 Given n1, n2, ..., nm determine the number of Young tables containing the elements 1, 2, ..., n1+n2+...+nm. Input The input has the stucture: on the first line is: the natural number m (1 <= m <= 20); on the second line are: the numbers n1, n2, ..., nm separated by a space (n1 <= 12). Output The output will contain the number of Young tables that can be built. Sample Input 2 3 2 Sample Output 5
JVM中奇怪的Full GC, 大家帮忙分析下
下面的gc log中的full gc是怎么触发的,理解不了,请大神看看~ ``` 2015-02-03T14:40:12.029+0800: 470.095: [GC [PSYoungGen: 1271672K->13218K(3940864K)] 1374109K->115656K(8135168K), 0.0061610 secs] [Times: user=0.05 sys=0.00, real=0.00 secs] 2015-02-03T14:40:12.036+0800: 470.101: [Full GC [PSYoungGen: 13218K->0K(3940864K)] [ParOldGen: 102437K->98542K(4194304K)] 115656K->98542K(8135168K) [PSPermGen: 64633K->64632K(262144K)], 0.3928440 secs] [Times: user=3.18 sys=0.02, real=0.40 secs] 2015-02-03T14:43:12.622+0800: 650.688: [GC [PSYoungGen: 2750752K->24677K(3932160K)] 2849294K->123219K(8126464K), 0.0274110 secs] [Times: user=0.06 sys=0.10, real=0.03 secs] 2015-02-03T14:43:12.650+0800: 650.715: [Full GC [PSYoungGen: 24677K->0K(3932160K)] [ParOldGen: 98542K->108727K(4194304K)] 123219K->108727K(8126464K) [PSPermGen: 65137K->65128K(262144K)], 0.4234160 secs] [Times: user=3.40 sys=0.03, real=0.42 secs] 2015-02-03T14:43:27.212+0800: 665.277: [GC [PSYoungGen: 828133K->12061K(3961344K)] 936860K->120788K(8155648K), 0.0092620 secs] [Times: user=0.05 sys=0.02, real=0.01 secs] 2015-02-03T14:43:27.221+0800: 665.287: [Full GC [PSYoungGen: 12061K->0K(3961344K)] [ParOldGen: 108727K->101742K(4194304K)] 120788K->101742K(8155648K) [PSPermGen: 65191K->65191K(262144K)], 0.2733550 secs] [Times: user=2.09 sys=0.01, real=0.27 secs] ``` 1. 从日志可以看出一些规律来,每次做完一次young gc会立马做一次full gc(时间几乎一致),此时young 区大小会变为0(开始大小和上一次young gc完的大小是一致的) 2. jdk版本为 1.7.0_55 3. JVM参数 -Xmx8192m -Xms8192m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=4 -XX:MaxPermSize=256m -XX:PermSize=256m
The Embarrassed Cryptographer 的程序的设计
Problem Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys are created from the product of two primes, and are believed to be secure because there is no known method for factoring such a product effectively. What Odd Even did not think of, was that both factors in a key should be large, not just their product. It is now possible that some of the users of the system have weak keys. In a desperate attempt not to be fired, Odd Even secretly goes through all the users keys, to check if they are strong enough. He uses his very poweful Atari, and is especially careful when checking his boss' key. Input The input consists of no more than 20 test cases. Each test case is a line with the integers 4 <= K <= 10100 and 2 <= L <= 106. K is the key itself, a product of two primes. L is the wanted minimum size of the factors in the key. The input set is terminated by a case where K = 0 and L = 0. Output For each number K, if one of its factors are strictly less than the required L, your program should output "BAD p", where p is the smallest factor in K. Otherwise, it should output "GOOD". Cases should be separated by a line-break. Sample Input 143 10 143 20 667 20 667 30 2573 30 2573 40 0 0 Sample Output GOOD BAD 11 GOOD BAD 23 GOOD BAD 31
Young
Description Consider m natural numbers n1, n2, ..., nm with the property n1 >= n2 >= ... >= nm > 0. We define a Young table as an arrangement in a table of n1 + n2 + ... + nm natural numbers (bigger than 0 and any two different), so that the ith line has ni elements (1 <= i <= m) in ascending order from left to right, and the elements from the same column are in ascending order from bottom to top. An example of Young table for m = 4, n1 = 6, n2 = 4, n3 = 4, n4 = 1 is the following: 1 2 5 9 10 15 3 6 7 13 4 8 12 14 11 Given n1, n2, ..., nm determine the number of Young tables containing the elements 1, 2, ..., n1+n2+...+nm. Input The input has the stucture: on the first line is: the natural number m (1 <= m <= 20); on the second line are: the numbers n1, n2, ..., nm separated by a space (n1 <= 12). Output The output will contain the number of Young tables that can be built. Sample Input 2 3 2 Sample Output 5
Get Luffy Out 程序问题
Problem Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlong's island. When he got there, he found the secret place where his friend was kept, but he could not go straight in. He saw a large door in front of him and two locks in the door. Beside the large door, he found a strange rock, on which there were some odd words. The sentences were encrypted. But that was easy for Ratish, an amateur cryptographer. After decrypting all the sentences, Ratish knew the following facts: Behind the large door, there is a nesting prison, which consists of M floors. Each floor except the deepest one has a door leading to the next floor, and there are two locks in each of these doors. Ratish can pass through a door if he opens either of the two locks in it. There are 2N different types of locks in all. The same type of locks may appear in different doors, and a door may have two locks of the same type. There is only one key that can unlock one type of lock, so there are 2N keys for all the 2N types of locks. These 2N keys were made N pairs,one key may be appear in some pairs, and once one key in a pair is used, the other key will disappear and never show up again. Later, Ratish found N pairs of keys under the rock and a piece of paper recording exactly what kinds of locks are in the M doors. But Ratish doesn't know which floor Luffy is held, so he has to open as many doors as possible. Can you help him to choose N keys to open the maximum number of doors? Input There are several test cases. Every test case starts with a line containing two positive integers N (1 <= N <= 2^10) and M (1 <= M <= 2^11) separated by a space, the first integer represents the number of types of keys and the second integer represents the number of doors. The 2N keys are numbered 0, 1, 2, ..., 2N - 1. Each of the following N lines contains two integers, which are the numbers of two keys in a pair. After that, each of the following M lines contains two integers, which are the numbers of two keys corresponding to the two locks in a door. You should note that the doors are given in the same order that Ratish will meet. A test case with N = M = 0 ends the input, and should not be processed. Output For each test case, output one line containing an integer, which is the maximum number of doors Ratish can open. Sample Input 3 6 0 3 1 2 4 5 0 1 0 2 4 1 4 2 3 5 2 2 0 0 Sample Output 4
Johnny and the Quadratic Equation 的设计的程序
Problem Description Johnny recently learned about this whole quadratic equation thing. Being an avid young programmer,he immediately wrote the following code that was supposed to help in his homework: #include<cstdio> int main() { unsigned int a,b,c,x=0; scanf("%u %u %u",&a,&b,&c); do { if (a*x*x+b*x+c==0) { puts("YES"); return 0; } x++; } while(x); puts("NO"); return 0; } where all calculations are performed on unsigned 32-bit integers (in other words, modulo 232). But,well, it turned out that this code runs rather slow, even on his recently updated monster gaming rig.Maybe you could help him? Input The input contains several test cases. The rst line contains an integer t (t <=104) denoting the number of test cases. Then t tests follow, each of them consisting of three space separated integers a, b and c (0 <= a, b, c < 232). Output For each test case output the answer of the program above. Sample Input 3 948 43958 1429912782 95348 54988 345335 943428 4353958 3444096692 Sample Output YES NO YES
Get Luffy Out 程序的设计
Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlong's island. When he got there, he found the secret place where his friend was kept, but he could not go straight in. He saw a large door in front of him and two locks in the door. Beside the large door, he found a strange rock, on which there were some odd words. The sentences were encrypted. But that was easy for Ratish, an amateur cryptographer. After decrypting all the sentences, Ratish knew the following facts: Behind the large door, there is a nesting prison, which consists of M floors. Each floor except the deepest one has a door leading to the next floor, and there are two locks in each of these doors. Ratish can pass through a door if he opens either of the two locks in it. There are 2N different types of locks in all. The same type of locks may appear in different doors, and a door may have two locks of the same type. There is only one key that can unlock one type of lock, so there are 2N keys for all the 2N types of locks. These 2N keys were divided into N pairs, and once one key in a pair is used, the other key will disappear and never show up again. Later, Ratish found N pairs of keys under the rock and a piece of paper recording exactly what kinds of locks are in the M doors. But Ratish doesn't know which floor Luffy is held, so he has to open as many doors as possible. Can you help him to choose N keys to open the maximum number of doors? Input There are several test cases. Every test case starts with a line containing two positive integers N (1 <= N <= 210) and M (1 <= M <= 211) separated by a space, the first integer represents the number of types of keys and the second integer represents the number of doors. The 2N keys are numbered 0, 1, 2, ..., 2N - 1. Each of the following N lines contains two different integers, which are the numbers of two keys in a pair. After that, each of the following M lines contains two integers, which are the numbers of two keys corresponding to the two locks in a door. You should note that the doors are given in the same order that Ratish will meet. A test case with N = M = 0 ends the input, and should not be processed. Output For each test case, output one line containing an integer, which is the maximum number of doors Ratish can open. Sample Input 3 6 0 3 1 2 4 5 0 1 0 2 4 1 4 2 3 5 2 2 0 0 Sample Output 4
Bishops 代码的思路
Problem Description Yesterday was Sam's birthday. The most interesting gift was definitely the chessboard. Sam quickly learned the rules of chess and defeated his father, all his friends, his little sister, and now no one wants to play with him any more. So he decided to play with another birthday gift – a Book of Math Problems for Young Mathematicians. He opened the book somewhere in the middle and read the following problem: "How many knights can be placed on a chessboard without threatening each other?" After a while he realized that this was trivial and moved on to the next problem: "How many bishops can be placed on a chessboard without threatening each other?". Sam is in trouble here. He is not able to solve this problem and needs your help. Task Specification Sam's chessboard has size N×N. A bishop can move to any distance in any of the four diagonal directions. A bishop threatens another bishop if it can move to the other bishop's position. Your task is to compute the maximum number of bishops that can be placed on a chessboard in such a way that no two bishops threaten each other. Input The input file consists of several lines. The line number i contains a single number representing the size( <10^100) of the i-th chessboard. Output The output file should contain the same number of lines as the input file. The i-th line should contain one number – the maximum number of bishops that can be placed on i-th chessboard without threatening each other. Sample Input 2 3 Sample Output 2 4
Constructing Roads In JGShining's Kingdom 如何完成代码
Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. Half of these cities are rich in resource (we call them rich cities) while the others are short of resource (we call them poor cities). Each poor city is short of exactly one kind of resource and also each rich city is rich in exactly one kind of resource. You may assume no two poor cities are short of one same kind of resource and no two rich cities are rich in one same kind of resource. With the development of industry, poor cities wanna import resource from rich ones. The roads existed are so small that they're unable to ensure the heavy trucks, so new roads should be built. The poor cities strongly BS each other, so are the rich ones. Poor cities don't wanna build a road with other poor ones, and rich ones also can't abide sharing an end of road with other rich ones. Because of economic benefit, any rich city will be willing to export resource to any poor one. Rich citis marked from 1 to n are located in Line I and poor ones marked from 1 to n are located in Line II. The location of Rich City 1 is on the left of all other cities, Rich City 2 is on the left of all other cities excluding Rich City 1, Rich City 3 is on the right of Rich City 1 and Rich City 2 but on the left of all other cities ... And so as the poor ones. But as you know, two crossed roads may cause a lot of traffic accident so JGShining has established a law to forbid constructing crossed roads. For example, the roads in Figure I are forbidden. In order to build as many roads as possible, the young and handsome king of the kingdom - JGShining needs your help, please help him. ^_^ Input Each test case will begin with a line containing an integer n(1 ≤ n ≤ 500,000). Then n lines follow. Each line contains two integers p and r which represents that Poor City p needs to import resources from Rich City r. Process to the end of file. Output For each test case, output the result in the form of sample. You should tell JGShining what's the maximal number of road(s) can be built. Sample Input 2 1 2 2 1 3 1 2 2 3 3 1 Sample Output Case 1: My king, at most 1 road can be built. Case 2: My king, at most 2 roads can be built.
Navy maneuvers 代码具体怎么写
Problem Description In times of peace, various countries have held regular maneuvers to maintain military’s vigilance. There is a navy fleet in a certain country which also starts a new round imaginary naval battle. At the maneuver stage, the admiral intends to assess the combat effectiveness of two warships, “Victory” and “Glory”, so he lets two warships carry out countering exercises. Both of the warship commanders are young and promising, who graduated from naval academy as outstanding students. Not only have they had rich navigation direction experiences, but also have profound scientific knowledge, especially in mathematics. The admiral appoints one marine area dotted with many islets. Suppose all these islets are occupied by the enemy, and there are positive integers of enemy firebases. The hypothetical exercise situations given by the admiral and the rule of the competition are as follows: (1) All the occupied islets are connected. There are some routes among these islets, but the route from one islet to another islet is unidirectional. In other words, if we take an islet as a node and an islet route as an edge, then we will get a directed non-cyclic connected graph. (2) There is a unique 1st islet in the graph. If we start from this islet, we can reach any other islet. (maybe the 1st islet is not the islet which is numbered 1) (3) At the beginning of the maneuver, two warships simultaneously sail to the 1st islets and eliminate all enemy firebases together. (4) The two warships, “Victory” and “Glory” take turns to navigate and exchange as soon as they arrive at an islet, then they move forward together. But each time they can only go along the unidirectional route, sail to the islet directly connected to the current, and eliminates all the enemy firebases on the islet. By the way, when start from 1st islet, “Victory” first navigates. (5) Because each route is unidirectional, and graph is non-cycle, therefore the maneuver terminates when the two warships fail to go on navigating. (6)When the maneuver ends, sum the numbers of eliminated enemy firebases on the routing path. If the number is greater than or equal to certain number f assigned by the admiral, then “Victory” wins. Otherwise, “Glory” wins. The warship commanders are both mathematicians. After being assigned to such task, they see it is a Graph Theory problem. On the first simple directed non-cyclic connected graph, each node has a certain positive integer,it indicates the enemy firebases. The assignment is that two captains take turn to move forward along the directed edge until they are unable to do so. Then sum the total positive integers of the nodes on the routing path. Compare the number with the certain number f, and decides the final winning or losses. Therefore, when it is the time for their own navigation, they are supposed to choose the route to win the final success. Input There are several test cases, in each case there are three positive integers n, m and f in first line. n indicates there are n (1< n <10000 ) nodes in the graph. The node serial number is arranged from 1 to n. m indicates that there are m edges in the graph. The following line has n positive integers, which indicate in sequence the positive integers in the nodes. Finally, there are m lines, and each line has two positive integers a, b (1< = a, b< =n), indicating there is a directed edge from the a node to the b node. Input is terminated by the end of file. Output To each group of the test case, if “Victory” wins, then output “Victory”. Otherwise, output “Glory”. The output each case takes up one line. Sample Input 4 4 7 2 2 2 2 4 2 2 1 4 3 3 1 4 5 6 1 2 3 4 1 2 1 3 1 4 2 3 4 3 Sample Output Glory Victory
很头疼一天了。。java.lang.NoSuchMethodException
![图片说明](https://img-ask.csdn.net/upload/201712/26/1514258910_543334.png) ![图片说明](https://img-ask.csdn.net/upload/201712/26/1514258929_437880.png) ``` SEVERE: Servlet.service() for servlet [MES] in context with path [/MES] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating class td.young.smp.entity.TSM_QPM_Q001 with invalid types () or values (). Cause: java.lang.NoSuchMethodException: td.young.smp.entity.TSM_QPM_Q001.<init>()] with root cause java.lang.NoSuchMethodException: td.young.smp.entity.TSM_QPM_Q001.<init>() ``` 究竟是为什么啊?不要和我说struts2的问题我就没有用这个框架,用的是ssm的。。
The Embarrassed Cryptographer
Problem Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys are created from the product of two primes, and are believed to be secure because there is no known method for factoring such a product effectively. What Odd Even did not think of, was that both factors in a key should be large, not just their product. It is now possible that some of the users of the system have weak keys. In a desperate attempt not to be fired, Odd Even secretly goes through all the users keys, to check if they are strong enough. He uses his very poweful Atari, and is especially careful when checking his boss' key. Input The input consists of no more than 20 test cases. Each test case is a line with the integers 4 <= K <= 10100 and 2 <= L <= 106. K is the key itself, a product of two primes. L is the wanted minimum size of the factors in the key. The input set is terminated by a case where K = 0 and L = 0. Output For each number K, if one of its factors are strictly less than the required L, your program should output "BAD p", where p is the smallest factor in K. Otherwise, it should output "GOOD". Cases should be separated by a line-break. Sample Input 143 10 143 20 667 20 667 30 2573 30 2573 40 0 0 Sample Output GOOD BAD 11 GOOD BAD 23 GOOD BAD 31
Eliminate the Conflict 冲突的问题
Problem Description Conflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be if all conflicts can be eliminated. Edward contributes his lifetime to invent a 'Conflict Resolution Terminal' and he has finally succeeded. This magic item has the ability to eliminate all the conflicts. It works like this: If any two people have conflict, they should simply put their hands into the 'Conflict Resolution Terminal' (which is simply a plastic tube). Then they play 'Rock, Paper and Scissors' in it. After they have decided what they will play, the tube should be opened and no one will have the chance to change. Finally, the winner have the right to rule and the loser should obey it. Conflict Eliminated! But the game is not that fair, because people may be following some patterns when they play, and if the pattern is founded by others, the others will win definitely. Alice and Bob always have conflicts with each other so they use the 'Conflict Resolution Terminal' a lot. Sadly for Bob, Alice found his pattern and can predict how Bob plays precisely. She is very kind that doesn't want to take advantage of that. So she tells Bob about it and they come up with a new way of eliminate the conflict: They will play the 'Rock, Paper and Scissors' for N round. Bob will set up some restricts on Alice. But the restrict can only be in the form of "you must play the same (or different) on the ith and jth rounds". If Alice loses in any round or break any of the rules she loses, otherwise she wins. Will Alice have a chance to win? Input The first line contains an integer T(1 <= T <= 50), indicating the number of test cases. Each test case contains several lines. The first line contains two integers N,M(1 <= N <= 10000, 1 <= M <= 10000), representing how many round they will play and how many restricts are there for Alice. The next line contains N integers B1,B2, ...,BN, where Bi represents what item Bob will play in the ith round. 1 represents Rock, 2 represents Paper, 3 represents Scissors. The following M lines each contains three integers A,B,K(1 <= A,B <= N,K = 0 or 1) represent a restrict for Alice. If K equals 0, Alice must play the same on Ath and Bth round. If K equals 1, she must play different items on Ath and Bthround. Output For each test case in the input, print one line: "Case #X: Y", where X is the test case number (starting with 1) and Y is "yes" or "no" represents whether Alice has a chance to win. Sample Input 2 3 3 1 1 1 1 2 1 1 3 1 2 3 1 5 5 1 2 3 2 1 1 2 1 1 3 1 1 4 1 1 5 1 2 3 0 Sample Output Case #1: no Case #2: yes
Rain in ACStar 设计
Problem Description Maybe you have heard of Super Cow AC who is the great general of ACM Empire. However, do you know where he is from? This is one of the ten biggest secrets of this world! And it is time to expose the truth! Yes, Super Cow AC is from ACStar which is ten million light-year away from our earth. No one, even AC himself, knows how AC came to our home. The only memory in his head is the strange rain in ACStar. Because of the special gravity of ACStar, the raindrops in ACStar have many funny features. They have arbitrary sizes, color and tastes. The most interesting parts of the raindrops are their shapes. When AC was very young, he found that all the drops he saw in air were convex hull. Once the raindrops fell to the ground, they would be absorb by the soil. This year is set to be AC-year. In recognition of Great General AC's contribution to our empire, the Emperor decided to build a huge AC park. Inside this park there is a laboratory to simulate the rain in ACStar. As a researcher of this lab, you are appointed to measure the volume of rain absorbed by soil. To simplify this problem, scientists put the rain into two-dimensional plane in which the ground is represented as a straight line and the raindrops are convex polygon. So the area of the graphics stands for the volume of raindrops. You will receive two types of instructions: 1.R P (This type of instructions tell you sufficient information about the raindrops.) 2.Q A B (Ask you to report the volume of rain absorbed by soil of [A,B].) Instructions are given in chronological order. Input The first line of the inputs is T(no more than 10), which stands for the number of test cases you need to solve. After T, the inputs will be each test case. The first line of each case will be N(no more than 25000), representing for the numbers of instructions. The following N lines will give instructions of the two types. For each instruction of type 1, it will be followed by a line listing P (at least 3 and at most 5) points representing the convex polygon of the coming raindrop. The points are started by the leftmost point and are given in counterclockwise order. It's guaranteed that no points of the same raindrop are in the same vertical line. All numbers are positive integer no more than 1000000000. Output For each instruction of type 2, output the corresponding result, which should be printed accurately rounded to three decimals. It is guaranteed that the result is less than 1e8. Sample Input 1 7 Q 1 100 R 4 10 10 11 10 13 11 12 11 Q 10 11 Q 1 100 R 3 100 20 120 20 110 30 Q 1 100 Q 12 120 Sample Output 0.000 0.250 1.000 1.000 100.250
Treasure of the Chimp Island
Problem Description Bob Bennett, the young adventurer, has found the map to the treasure of the Chimp Island, where the ghost zombie pirate LeChimp, the infamous evil pirate of the Caribbeans has hidden somewhere inside the Zimbu Memorial Monument (ZM2). ZM2 is made up of a number of corridors forming a maze. To protect the treasure, LeChimp has placed a number of stone blocks inside the corridors to block the way to the treasure. The map shows the hardness of each stone block which determines how long it takes to destroy the block. ZM2 has a number of gates on the boundary from which Bob can enter the corridors. Fortunately, there may be a pack of dynamites at some gates, so that if Bob enters from such a gate, he may take the pack with him. Each pack has a number of dynamites that can be used to destroy the stone blocks in a much shorter time. Once entered, Bob cannot exit ZM2 and enter again, nor can he walk on the area of other gates (so, he cannot pick more than one pack of dynamites). The hardness of the stone blocks is an integer between 1 and 9, showing the number of days required to destroy the block. We neglect the time required to travel inside the corridors. Using a dynamite, Bob can destroy a block almost immediately, so we can ignore the time required for it too. The problem is to find the minimum time at which Bob can reach the treasure. He may choose any gate he wants to enter ZM2. Input The input consists of multiple test cases. Each test case contains the map of ZM2 viewed from the above. The map is a rectangular matrix of characters. Bob can move in four directions up, down, left, and right, but cannot move diagonally. He cannot enter a location shown by asterisk characters (*), even using all his dynamites! The character ($) shows the location of the treasure. A digit character (between 1 and 9) shows a stone block of hardness equal to the value of the digit. A hash sign (#) which can appear only on the boundary of the map indicates a gate without a dynamite pack. An uppercase letter on the boundary shows a gate with a pack of dynamites. The letter A shows there is one dynamite in the pack, B shows there are two dynamite in the pack and so on. All other characters on the boundary of the map are asterisks. Corridors are indicated by dots (.). There is a blank line after each test case. The width and the height of the map are at least 3 and at most 100 characters. The last line of the input contains two dash characters (--). Output For each test case, write a single line containing a number showing the minimum number of days it takes Bob to reach the treasure, if possible. If the treasure is unreachable, write IMPOSSIBLE. Sample Input *****#********* *.1....4..$...* *..***..2.....* *..2..*****..2* *..3..******37A *****9..56....* *.....******..* ***CA********** ***** *$3** *.2** ***#* -- Sample Output 1 IMPOSSIBLE
Navy maneuvers 的代码设计
Problem Description In times of peace, various countries have held regular maneuvers to maintain military’s vigilance. There is a navy fleet in a certain country which also starts a new round imaginary naval battle. At the maneuver stage, the admiral intends to assess the combat effectiveness of two warships, “Victory” and “Glory”, so he lets two warships carry out countering exercises. Both of the warship commanders are young and promising, who graduated from naval academy as outstanding students. Not only have they had rich navigation direction experiences, but also have profound scientific knowledge, especially in mathematics. The admiral appoints one marine area dotted with many islets. Suppose all these islets are occupied by the enemy, and there are positive integers of enemy firebases. The hypothetical exercise situations given by the admiral and the rule of the competition are as follows: (1) All the occupied islets are connected. There are some routes among these islets, but the route from one islet to another islet is unidirectional. In other words, if we take an islet as a node and an islet route as an edge, then we will get a directed non-cyclic connected graph. (2) There is a unique 1st islet in the graph. If we start from this islet, we can reach any other islet. (maybe the 1st islet is not the islet which is numbered 1) (3) At the beginning of the maneuver, two warships simultaneously sail to the 1st islets and eliminate all enemy firebases together. (4) The two warships, “Victory” and “Glory” take turns to navigate and exchange as soon as they arrive at an islet, then they move forward together. But each time they can only go along the unidirectional route, sail to the islet directly connected to the current, and eliminates all the enemy firebases on the islet. By the way, when start from 1st islet, “Victory” first navigates. (5) Because each route is unidirectional, and graph is non-cycle, therefore the maneuver terminates when the two warships fail to go on navigating. (6)When the maneuver ends, sum the numbers of eliminated enemy firebases on the routing path. If the number is greater than or equal to certain number f assigned by the admiral, then “Victory” wins. Otherwise, “Glory” wins. The warship commanders are both mathematicians. After being assigned to such task, they see it is a Graph Theory problem. On the first simple directed non-cyclic connected graph, each node has a certain positive integer,it indicates the enemy firebases. The assignment is that two captains take turn to move forward along the directed edge until they are unable to do so. Then sum the total positive integers of the nodes on the routing path. Compare the number with the certain number f, and decides the final winning or losses. Therefore, when it is the time for their own navigation, they are supposed to choose the route to win the final success. Input There are several test cases, in each case there are three positive integers n, m and f in first line. n indicates there are n (1< n <10000 ) nodes in the graph. The node serial number is arranged from 1 to n. m indicates that there are m edges in the graph. The following line has n positive integers, which indicate in sequence the positive integers in the nodes. Finally, there are m lines, and each line has two positive integers a, b (1< = a, b< =n), indicating there is a directed edge from the a node to the b node. Input is terminated by the end of file. Output To each group of the test case, if “Victory” wins, then output “Victory”. Otherwise, output “Glory”. The output each case takes up one line. Sample Input 4 4 7 2 2 2 2 4 2 2 1 4 3 3 1 4 5 6 1 2 3 4 1 2 1 3 1 4 2 3 4 3 Sample Output Glory Victory
相见恨晚的超实用网站
相见恨晚的超实用网站 持续更新中。。。
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
python学习方法总结(内附python全套学习资料)
不要再问我python好不好学了 我之前做过半年少儿编程老师,一个小学四年级的小孩子都能在我的教学下独立完成python游戏,植物大战僵尸简单版,如果要肯花时间,接下来的网络开发也不是问题,人工智能也可以学个调包也没啥问题。。。。。所以python真的是想学就一定能学会的!!!! --------------------华丽的分割线-------------------------------- ...
python 简易微信实现(注册登录+数据库存储+聊天+GUI+文件传输)
socket+tkinter详解+简易微信实现 历经多天的努力,查阅了许多大佬的博客后终于实现了一个简易的微信O(∩_∩)O~~ 简易数据库的实现 使用pands+CSV实现数据库框架搭建 import socket import threading from pandas import * import pymysql import csv # 创建DataFrame对象 # 存储用户数据的表(...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
Python实例大全(基于Python3.7.4)
博客说明: 这是自己写的有关python语言的一篇综合博客。 只作为知识广度和编程技巧学习,不过于追究学习深度,点到即止、会用即可。 主要是基础语句,如三大控制语句(顺序、分支、循环),随机数的生成,数据类型的区分和使用; 也会涉及常用的算法和数据结构,以及面试题相关经验; 主体部分是针对python的数据挖掘和数据分析,主要先攻爬虫方向:正则表达式匹配,常用数据清洗办法,scrapy及其他爬虫框架,数据存储方式及其实现; 最后还会粗略涉及人工智能领域,玩转大数据与云计算、进行相关的预测和分析。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
JavaScript 为什么能活到现在?
作者 | 司徒正美 责编 |郭芮 出品 | CSDN(ID:CSDNnews) JavaScript能发展到现在的程度已经经历不少的坎坷,早产带来的某些缺陷是永久性的,因此浏览器才有禁用JavaScript的选项。甚至在jQuery时代有人问出这样的问题,jQuery与JavaScript哪个快?在Babel.js出来之前,发明一门全新的语言代码代替JavaScript...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
吐血推荐珍藏的Visual Studio Code插件
作为一名Java工程师,由于工作需要,最近一个月一直在写NodeJS,这种经历可以说是一部辛酸史了。好在有神器Visual Studio Code陪伴,让我的这段经历没有更加困难。眼看这段经历要告一段落了,今天就来给大家分享一下我常用的一些VSC的插件。 VSC的插件安装方法很简单,只需要点击左侧最下方的插件栏选项,然后就可以搜索你想要的插件了。 下面我们进入正题 Material Theme ...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
相关热词 c#中dns类 c#合并的excel c# implicit c#怎么保留3个小数点 c# 串口通信、 网络调试助手c# c# 泛型比较大小 c#解压分卷问题 c#启动居中 c# 逻辑或运算符
立即提问

相似问题

0
判断四个点能否组成正方形的一个算法的问题,如何利用C语言程序的设计的方式来做
0
结果方向性的判定的算法的数据结构,如何使用c程序的编程语言的设计实现的方式
0
QSC码的一个计算的问题,采用C语言的程序的设计的方式怎么来实现这个算法的
0
连通图上的点的可达性的判断的算法问题,怎么利用C语言的程序的设计的方式来实现的?
0
数据结构方面一个数据的整合的算法,利用C程序的语言的编程的技术的实现的做法怎么实现?
0
藏宝地图遍历的一个算法问题,运用数据结构怎么采用C语言的程序的设计的方式实现?
0
计算可以获取到的最高的分数的值,运用C语言程序代码实现编写的过程是什么
0
设计一个带有优先级的队列的问题,运用的是C语言的程序代码编写的设计的思维的方式?
0
双倍的队列的问题,这种数据结构的程序用C语言的代码如何才能正确地实现的呢?
0
字符串快速查找算法的问题,怎么使用 C 语言的程序的编写的办法怎么来查找的?
0
数据结构里面的Double Queue问题,怎么使用的C语言的程序编写的代码的过程的当时有效解决的
0
如何排除掉冲突的项,怎么用C语言的程序具体的思想来编写出的代码的过程去实现的排除
0
计算僧侣的战斗记录问题用的数据结构,是怎么使用C语言的程序代码编写设计的思想怎么来实现呢
0
分段路径求和的计算问题的数据结构怎么用C语言的程序设计思想编写出来的程序代码来实现的
0
计算线性序列的节点编号问题,怎么使用C语言的程序设计思想的办法有效解决计算问题
0
输出多项式的系数使得给定的方程成立,怎么用C语言的程序的设计的代码编写的思想方法来实现的
0
输出二维平面凸多边形的问题,使用C程序的代码设计的方式和步骤来计算的实现的思路
0
推算加密的密钥的问题,怎么使用C语言的程序的代码的编写的设计的技术实现的
0
路径搜索计算可以到达宝藏的最短时间,怎么采用C语言的程序代码的设计的过程便写什么代码
0
选择赢得最后成功的路线的策略,要求用C语言的程序的编写的技术方式加以实现