int main(void)//检查数中重复出现的数字
bool digit_seen[10]={false}
int digit;
long n;
printf("Enter a number:");
if (digit_seen[digit])
if (n>0)
printf("Repeatd digit\n");
printf("No repeated digit\n");
return 0;






Csdn user default icon
#include<stdio.h> #define true 1 #define false 0 typedef int bool; int main(void)//检查数中重复出现的数字 { bool digit_seen[10]={false}; int digit; long n; printf("Enter a number:"); scanf("%d",&n); while(n>0){ digit=n%10; if (digit_seen[digit]==true) break; digit_seen[digit]=true; n/=10; } if(n>0) printf("Repeatd digit(s):\n"); else printf("No repeated digit\n"); return 0; } 我的思路是设一个数组,把有重复的digit存入数组中,下标循环自加。但是首先你不知道会有多少个重复,所以数组的长度也定不了。。。。 另外实现的结果应为: Enter a number:939577 Repeated digit: 7 9
Rightmost Digit
Problem Description Given a positive integer N, you should output the most right digit of N^N. Input The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single positive integer N(1<=N<=1,000,000,000). Output For each test case, you should output the rightmost digit of N^N. Sample Input 2 3 4 Sample Output 7 6
Leftmost Digit 解决的办法
Problem Description Given a positive integer N, you should output the leftmost digit of N^N. Input The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single positive integer N(1<=N<=1,000,000,000). Output For each test case, you should output the leftmost digit of N^N. Sample Input 2 3 4 Sample Output 2 2
Last non-zero Digit in N! 编程的手段
Problem Description The expression N!, read as "N factorial," denotes the product of the first N positive integers, where N is nonnegative. So, for example, N N! 0 1 1 1 2 2 3 6 4 24 5 120 10 3628800 For this problem, you are to write a program that can compute the last non-zero digit of the factorial for N. For example, if your program is asked to compute the last nonzero digit of 5!, your program should produce "2" because 5! = 120, and 2 is the last nonzero digit of 120. Input Input to the program is a series of nonnegative integers, each on its own line with no other letters, digits or spaces. For each integer N, you should read the value and compute the last nonzero digit of N!. Output For each integer input, the program should print exactly one line of output containing the single last non-zero digit of N!. Sample Input 1 2 26 125 3125 9999 Sample Output 1 2 4 8 2 8
Catch the Bus!
Problem Description ACM needs to deliver marketing materials to one of their clients. Both ACM and the client employ students to make such deliveries. And these students use public buses to move throughout the city. Sometimes, it is necessary to pass the materials as fast as possible. You are given bus timetables and your task is to find the fastest way for two students to meet at some stop. The place of the meeting is not important, they only need to meet as early as possible. Students may change between any two bus routes at stops that are common for both routes. At least two minutes are needed for every such change. No additional time is necessary to get on the first bus or to meet the other student in the target stop. Input The input contains a sequence of several scenarios, the sequence is terminated by a line containing negative number. Each scenario begins with a non-negative integer L, the number of bus routes that operate in the city (L ≤ 1000). Every route is then described by two lines. The first line contains names of stops that the bus runs through. Between each consecutive stops, there is a non-negative integer specifying the number of minutes required to travel between these stops with the given bus. The last stop is followed by a negative number. The second line of each bus route contains non-negative integers separated with spaces. The first integer H gives the number of buses that depart the initial stop in every hour (H ≤ 60). The remaining H integers are always distinct and sorted ascendingly, they list the minutes of departure (between 0 and 59). The timetable repeats every hour. For example, if the second line says “2 00 30”, the buses leave the initial stop at 12:00, 12:30, 13:00, 13:30, 14:00, etc. After the description of routes, there are two lines that specify the initial position of students. Each of them will contain time in a standard 24-hour format (one or two digits for hours, colon, and two digits for minutes) and a stop name. All numbers, times, and stop names will be separated with a single space. Stop names are case-sensitive and may be composed only from lower-case and upper-case letters, their length will not exceed 30 characters. The total number of stops will be at most 1000, the number of stops on a single route will not exceed 100. The time between any two consecutive stops will be at most one hour. The routes are considered one-way, if they operate in both directions, they will be given as two separate routes. A route may run through the same stop several times. Output For each test scenario, output a single line containing the earliest possible time the students can meet at any of the stops. The time must appear in the standard 24-hour format, hours given as a number between 0 and 23, then colon and minutes between 0 and 59. For hour values less than 10, only one digit must be used. Be aware of the fact that both students start their trip on the same day but may meet on another day, if the required time exceeds midnight. If the students are not able to meet in some scenario, output the words “No connection” instead of the time. Sample Input 4 Hradcanska 2 Malostranska 2 Staromestska 2 Mustek 1 Muzeum -1 10 00 06 12 18 24 30 36 42 48 54 Muzeum 1 Mustek 2 Staromestska 2 Malostranska 2 Hradcanska -1 10 03 09 15 21 27 33 39 45 51 57 Andel 2 Karlovo 1 Narodni 2 Mustek 2 Florenc -1 6 00 10 20 30 40 50 Florenc 2 Mustek 2 Narodni 3 Karlovo 1 Andel -1 6 02 12 22 32 42 52 12:00 Hradcanska 12:11 Andel 1 Hradcanska 2 Malostranska 2 Staromestska 2 Mustek 1 Muzeum 2 Hradcanska -1 10 00 06 12 18 24 30 36 42 48 54 12:00 Mustek 12:00 Andel -1 Sample Output 12:20 No connection
The Game of 31 游戏的算法
Problem Description The game of 31 was a favourite of con artists who rode the railroads in days of yore. The game is played with a deck of 24 cards: four labelled each of 1, 2, 3, 4, 5, 6. The cards in the deck are visible to both players, who alternately withdraw one card from the deck and place it on a pile. The object of the game is to be the last player to lay a card such that the sum of the cards in the pile does not exceed 31. Your task is to determine the eventual winner of a partially played game, assuming each player plays the remainder of the game using a perfect strategy. For example, in the following game player B wins: Player A plays 3 Player B plays 5 Player A plays 6 Player B plays 6 Player A plays 5 Player B plays 6 Input The input will consist of several lines; each line consists of a sequence of zero or more digits representing a partially completed game. The first digit is player A's move; the second player B's move; and so on. You are to complete the game using a perfect strategy for both players and to determine who wins. Output For each game, print a line consisting of the input, followed by a space, followed by A or B to indicate the eventual winner of the game. Sample Input 356656 35665 3566 111126666 552525 Sample Output 356656 B 35665 B 3566 A 111126666 A 552525 A
猜测数字的问题,Digit Puzzle
Problem Description If you hide some digits in an integer equation, you create a digit puzzle. The figure below shows two valid digit puzzles.Hidden digits are represented by squares, and other digits are shown. The numbers involved in this problem are all positive integers, written in decimal forms without leading zeros. If a digit puzzle has a unique solution, we call it a good puzzle. Both puzzles shown above are good puzzles. The solution to the first puzzle is 7*12=84, while the solution to the second one is 11*11=121. You are already given some digit puzzles, but some of them are not good. Your task is to convert these puzzles into good ones. You can change any wildcard character (i.e. hidden digits) into a real digit, any real digit to a wildcard character, or a real digit to another real digit, but you cannot insert or remove any character at any place. The number of changed characters should be minimized. In this problem, the puzzle is always in the form "a x b = c", and "a x b" and "b x a" should be considered different if a is not equal to b. It is allowed that all digits of both a and b are shown (e.g 12 x 34 = ****), though that puzzle is actually a simple multiplication problem. Write a program to make good puzzles. Input The input contains several test cases. Each test case contains three non-empty strings, x, y, z, having at most 2, 2 and 4 characters respectively. Each character is a digit or a wildcard '*', x will not begin with a zero character. The last test case is followed by a single zero, which should not be processed. Output For each test case, print the case number and the converted puzzle. If more than one optimal solution is found, the lexicographically first one should be printed (remember that "*" is before "0"). There is always a solution. Sample Input 7 ** 8* ** ** *** 0 Sample Output Case 1: 7 ** 8* Case 2: ** ** 1*1
Cover Up
Problem Description “The Price is Right” is a popular game show where contestants play various games to win fabulous prizes. One of the games played on the show is called “Cover Up” whose object is to guess a 5-digit number (actually, the price of a new car). In the actual game, contestants are given two numbers to choose from for the first digit, three numbers to choose from for the second digit, and so on. A contestant selects one number for each digit (from the set of yet unpicked numbers for that digit) and then is told which ones are correct; if at least one is correct, the player is allowed to guess again for all incorrect digits. The contestant keeps guessing as long as they keep getting at least one new digit correct. The game ends when either all the digits are correct (a win for the contestant) or after a turn when no new digit is guessed correctly (a loss). Typically this game is not sheer luck. For example, suppose you had the following five possibilities for the last digit: 1, 3, 5, 8 and 9. Many car prices end with either a 5 or a 9, so you might have, say, a 70% chance that one of these two numbers is correct; this breaks down to a 35% chance for either the 5 or the 9 and a 10% chance for each of the other three digits. Now say you pick the 5 and it’s wrong, but some other guess you made was right so you still get to play. With this additional information the probabilities for the remaining 4 numbers change: the probability for the 9 is now close to around 54%, while each of the other three numbers now has a little over a 15% chance. (We’ll let you figure out how we got these values). We’ll call the 5 and the 9 in the original group the known candidates, and typically there are known candidates in other columns as well. For example, if the two numbers for the first (high order) digit are 1 and 9, the contestant can be 100% sure that the 1 is the correct digit (there aren’t too many $90,000 cars to be given away). For this problem, you are to determine the probability of winning the game if an optimal strategy for picking the numbers (based on probabilities such as those described above) is used. Input Each test case will consist of two lines. The first will be n, the number of digits in the number to be guessed. The maximum value of n will be 5. The second line will contain n triplets of numbers of the form m l p where m is the number of choices for a digit, l is the number of known candidates, and p is the probability that one of the known candidates is correct. In all cases 0 ≤ l < m ≤ 10 and 0.0 ≤ p ≤ 1.0. Whenever l = 0 (i.e., when there are no known candidates) p will always be 0.0. A line containing a single 0 will terminate the input. Output Output for each test case is the probability of winning using optimal strategy. All probabilities should be rounded to the nearest thousandth, and trailing 0’s should not be output. (A 100% chance of winning should be output as 1.) Sample Input 2 3 1 0.8 2 0 0.0 2 3 2 0.8 2 0 0.0 2 3 2 0.82 2 1 0.57 3 4 1 1.0 3 0 0.0 10 1 1.0 0 Sample Output 0.85 0.6 0.644 1
Digital Roots 的问题
Problem Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit. For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39. Input The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero. Output For each integer in the input, output its digital root on a separate line of the output. Sample Input 24 39 0 Sample Output 6 3
Count Problem 的编写
Problem Description In this problem,we need to count the number that accord with the following rule(include the input number n).Read a integer number n(1<=n<=2^31 - 1) first,then do as following ways: (1)Do nothing, then exit the process. (2)Add a digit to the left of it,but the digit should not bigger than the half of the original first digit.For example,from 36 to 136 is legal,but 36 to 236 is illegal because 2 is bigger than half of 3. (3)After add the digit,continue the process,until could not add digit anymore. Input The first line of the input contains an integer T which means the number of test cases.Then T lines follow, each line starts with a number n(1<=n<=2^31 - 1). Output For each test case, you should output one line contains the number that accord with the rule start from n. Sample Input 2 1 6 Sample Output 1 6
Grade School Multiplication 乘法问题
Problem Description An educational software company, All Computer Math (ACM), has a section on multiplication of integers. They want to display the calculations in the traditional grade school format, like the following computation of 432 × 5678: 432 5678 ------- 3456 3024 2592 2160 ------- 2452896 Note well that the final product is printed without any leading spaces, but that leading spaces are necessary on some of the other lines to maintain proper alignment. However, as per our regional rules, there should never be any lines with trailing white space. Note that the lines of dashes have length matching the final product. As a special case, when one of the digits of the second operand is a zero, it generates a single 0 in the partial answers, and the next partial result should be on the same line rather than the next line down. For example, consider the following product of 200001 × 90040: 200001 90040 ----------- 8000040 180000900 ----------- 18008090040 The rightmost digit of the second operand is a 0, causing a 0 to be placed in the rightmost column of the first partial product. However, rather than continue to a new line, the partial product of 4 × 200001 is placed on the same line as that 0. The third and fourth least-significant digits of the second operand are zeros, each resulting in a 0 in the second partial product on the same line as the result of 9 × 200001. As a final special case, if there is only one line in the partial answer, it constitutes a full answer, and so there is no need for computing a sum. For example, a computation of 246 × 70 would be formatted as 246 70 ----- 17220 Your job is to generate the solution displays. Input The input contains one or more data sets. Each data set consists of two positive integers on a line, designating the operands in the desired order. Neither number will have more than 6 digits, and neither will have leading zeros. After the last data set is a line containing only 0 0. Output For each data set, output a label line containing "Problem " with the number of the problem, followed by the complete multiplication problem in accordance with the format rules described above. Sample Input 432 5678 200001 90040 246 70 0 0 Sample Output Problem 1 432 5678 ------- 3456 3024 2592 2160 ------- 2452896 Problem 2 200001 90040 ----------- 8000040 180000900 ----------- 18008090040 Problem 3 246 70 ----- 17220
Escape 逃脱问题
Problem Description 2012 If this is the end of the world how to do? I do not know how. But now scientists have found that some stars, who can live, but some people do not fit to live some of the planet. Now scientists want your help, is to determine what all of people can live in these planets. Input More set of test data, the beginning of each data is n (1 <= n <= 100000), m (1 <= m <= 10) n indicate there n people on the earth, m representatives m planet, planet and people labels are from 0. Here are n lines, each line represents a suitable living conditions of people, each row has m digits, the ith digits is 1, said that a person is fit to live in the ith-planet, or is 0 for this person is not suitable for living in the ith planet. The last line has m digits, the ith digit ai indicates the ith planet can contain ai people most.. 0 <= ai <= 100000 Output Determine whether all people can live up to these stars If you can output YES, otherwise output NO. Sample Input 1 1 1 1 2 2 1 0 1 0 1 1 Sample Output YES NO
ISBN 的问题
Problem Description Farmer John's cows enjoy reading books, and FJ has discovered that his cows produce more milk when they read books of a somewhat intellectual nature. He decides to update the barn library to replace all of the cheap romance novels with textbooks on algorithms and mathematics. Unfortunately, a shipment of these new books has fallen in the mud and their ISBN numbers are now hard to read. An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. To verify that an ISBN number is correct, you calculate a sum that is 10 times the first digit plus 9 times the second digit plus 8 times the third digit ... all the way until you add 1 times the last digit. If the final number leaves no remainder when divided by 11, the code is a valid ISBN. For example 0201103311 is a valid ISBN, since 10*0 + 9*2 + 8*0 + 7*1 + 6*1 + 5*0 + 4*3 + 3*3 + 2*1 + 1*1 = 55. Each of the first nine digits can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number. Your task is to fill in the missing digit from a given ISBN number where the missing digit is represented as '?'. Input * Line 1: A single line with a ten digit ISBN number that contains '?' in a single position Output * Line 1: The missing digit (0..9 or X). Output -1 if there is no acceptable digit for the position marked '?' that gives a valid ISBN. Sample Input 15688?111X Sample Output 1
QR 的问题
Problem Description QR Codes (the smallest, which is 21 pixels by 21 pixels, is shown below) are square arrays of black or white pixels (modules) which include Position Detection Patterns (the square bull's-eye patterns), Timing Patterns (the alternating black and white lines), Alignment Patterns in larger QR Codes , Format Information (the stippled pixels), Version information in larger QR Codes and Data and Error Correction Codewords (gray 8 pixel blocks). The 21-by-21 QR Code has 26 data and error correction codewords. At the lowest error correction level for this code, 19 are data codewords and 7 are error correction codewords. Data may be encoded as numeric at 3 numbers per 10 bits, as alphanumeric at 2 characters per 11 bits, as 8 bit bytes or as Kanji at 13 bits per character. Data is encoded in groups of(mode,character count,character data bits).The mode can change within the data stream. The mode is specified by a 4 bit code and the character count by a varying number of bits depending on the mode and QR Code size. For the 21-by-21 code, the character count bits are: The entire data stream ends in the termination code which may be truncated if there is not enough room. Any partially filled codeword after the termination code is filled with 0 bits. Any remaining codewords are set to 11101100 followed by 00010001 alternating. Numeric strings are encoded 3 digits at a time. If there are remaining digits, 2 digits are encoded in 7 bits or 1 digit in 4 bits. For example: 12345678 -> 123 456 78 -> 0001111011 0111001000 1001110 Prefix with mode (0001) and count (8 -> 0000001000) is (4 + 10 + 10 + 10 +7) bits: 0001 0000001000 0001111011 0111001000 1001110 Alphanumeric strings encode the haracters (<SP> represents the space character): 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<SP>$%*+-./: as numbers from 0 to 44, then two characters are encoded in 11 bits: <first char code5> * 45 + <second char code> if the number of characters is odd, the last character is encoded in 6 bits. For example: AC-42 -> (10,12,41,4,2) -> 10*45+12=462, 41*45+4=1849, 2->00111001110 11100111001 000010 Prefix with mode and count is (4 + 9 + 11 + 11+ 6) bits: 0010 000000101 00111001110 11100111001 000010 The 8 bit binary and Kanji modes will be straightforward for the purposes of this problem. Kanji codes will just be opaque 13 bit codes; you need not decode the characters they represent, just the hexadecimal values. For example: 8 bit 0x45 0x92 0xa3 -> 01000101 10010010 10100011 Prefix with mode and count is (4 + 8 + 8 + 8 + 8) bits: 0100 00000011 01000101 10010010 10100011 Kanji 0x1ABC 07x0345 -> 1101010111100 0001101000101 Prefix with mode and count is (4 + 8 + 13 + 13) bits: 1000 00000010 1101010111100 0001101000101 To illustrate forming the 19 codeword content of a QR Code, combine the first 3 sequences above (for numeric, alphanumeric and bytes). Concatenate the bits, split into 8bit code words add the termination codeword, any fill bits and fill bytes (41 + 41 + 36 data bits + 4 bit termination code = 122 -> 6 fill bits are needed to get 16 bytes, and to fill out the 19 bytes, 3 fill bytes are needed): 0001 0000001000 0001111011 0111001000 1001110 0010 000000101 00111001110 11100111001 000010 0100 00000011 01000101 10010010 10100011 0000 000000 11101100 00010001 11101100 split into 8 bit codewords: 00010000 00100000 01111011 01110010 00100111 00010000 00010100 11100111 01110011 10010000 10010000 00001101 00010110 01001010 10001100 00000000 11101100 00010001 11101100 -> HEX 10207B72271014E77390900D164A8C0EC11EC Write a program to read 19 codewords and print the orresponding data. Input The first line of input contains a single integer P, (1 <= P <= 1000), which is the number of data sets that follow. Each data set is a single line of input consisting of the data set number, N, followed by a single space and 38 hexadecimal digits giving the 19 bytes of QR Code data. The valid hexadecimal digits are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. Output For each data set there is one line of output. It contains the data set number (N) followed by a single space, the number of QR decoded characters in the result, a single space and the character string corresponding to the QR Code data. In the output string, printable ASCII characters (in the range 0x20 to 0x7e) are printed as the ASCII character EXCEPT that backslash (\) is printed as \\ and pound sign (#) is printed as \#. Non-printable 8 bit data is output as \xx, where x is a hexadecimal digit (e.g. \AE). Non-printable 8 bit data is any value that is less than the ASCII value of a space (0x20) or greater than 0x76. 13 bit Kanji values are printed as #bxxx, where b is 0 or 1 and x is a hexadecimal digit (e.g. #13AC). Sample Input 4 1 10207B72271014E77390900D164A8C00EC11EC 2 802D5E0D1400EC11EC11EC11EC11EC11EC11EC 3 20BB1AA65F9FD7DC0ED88C973E15EF533EB0EC 4 2010B110888D9428D937193B9CEA0D7F45DF68 Sample Output 1 16 12345678AC-42E\92\A3 2 2 #1ABC#0345 3 23 HTTP://WWW.ACMGNYR.ORG/ 4 36 3.1415926535897932384626433832795028
用函数实现统计字符串中,字母和数字及不包括子母及数字的个数,在函数外输入 字符串并输出统计结果。 def Dcount(str): alph=digit=other=0 for i in str: if______ .isalpha()==True: alph+=1 elif______ .isdigit()==True: digit+=1 else:other+=1 return alph,digit,other x=(input()) print("alph=%d,digit=%d,other=%d"%Dcount(x))
locker 如何来实现的
Problem Description A password locker with N digits, each digit can be rotated to 0-9 circularly. You can rotate 1-3 consecutive digits up or down in one step. For examples: 567890 -> 567901 (by rotating the last 3 digits up) 000000 -> 000900 (by rotating the 4th digit down) Given the current state and the secret password, what is the minimum amount of steps you have to rotate the locker in order to get from current state to the secret password? Input Multiple (less than 50) cases, process to EOF. For each case, two strings with equal length (≤ 1000) consists of only digits are given, representing the current state and the secret password, respectively. Output For each case, output one integer, the minimum amount of steps from the current state to the secret password. Sample Input 111111 222222 896521 183995 Sample Output 2 12
Generator 生成器的问题
Problem Description We can generate a random string by generating a sequence of random characters and concatenating them together. Each character is chosen independently from the first n letters in the English alphabet with equal probability. Only capital letters are used in this problem. The generation is stopped as soon as one of specific patterns occurs in the random string. Your task is to predict the expected length of the generated string. Input Standard input will contain multiple test cases. First line is the number of case x. Each test case consists of integer N (1<=N<=8) which is the number of letters used, and M (1<=M<=10) which is the number of patterns used. The following M lines contain the patterns which are non-empty strings consisting of letters chosen from the first N upper case English letters. The length of any pattern will not exceed 10. Output For each test case, print the expected length of the generated random string. All output numbers are rounded to the second digit after the decimal point. Sample Input 4 2 1 A 2 1 ABA 3 1 AAAAA 2 2 A AA Sample Output 2.00 10.00 363.00 2.00
Count Cross 交叉的计算
Problem Description Given a MM×NN grid with different colors(black and white) on each cell, your task is to calculate the total amount of crosses of black color. We say there exists a black cross centered at the black cell (x,y) if there are four positive integer L,R,U,D that the cell(x,y-L),(x,y+R),(x-U,y),(x+D,y) are all black. Note that if two crosses have the same center but different L,R,U,D, we consider they are distinct.We use 1 to describe black. For example 00100 00100 11111 00100 00100 00000 There are 16 black crosses. The MM and NN are large, so we divide the matrix into M×N rectangle blocks.If two cells are in the same block ,their colors are same. So we can divide the sample into 4×3 blocks. Input There are at most 100 cases. In every case,there are two integers, M, N in the first line. (1≤M, N≤50) The next line contains M positive integers which are less than or equals to 50. The p-th integer describe the p-th row block's height. The next line contains N positive integers which are less than or equals to 50. The p-th integer describe the p-th colomn block's width. The following M lines each has a string which contain N digits.The q-th digit in the p-th line describe the color of the q-th colomn block in the p-th row. Output Output the answer to each case. Sample Input 4 3 2 1 2 1 2 1 2 010 111 010 000 Sample Output 16
Alarm Clock 的问题求解
Problem Description Advanced courses in computer science often include many interesting optimization problems. The following optimization problem is not advanced, nor is it particularly interesting. You are to write a program to determine the minimum number of buttons a person must push to set their alarm clock. Assume the alarm clock has 7 buttons – hour-up, hour-down, tens-minute-up, and tens-minute-down, ones-minute-up, ones-minute-down, and am/pm. For example, continuously pushing the hour-up button will cause hour digit to go through the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, …. Pushing the hour-down button will cause the sequence to go in the reverse order. Pushing the tens-minute-up buttons cycles tens minute digit through the numbers 0, 1, 2, 3, 4, 5, 0, 1, … Pushing the ones-minute-up button cycles the one digit through the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, … Pushing the am/pm button causes toggles the am/pm indicator. Input The first line of input will contain an integer indicating the number of problems that need to be processed. Each line will contain two times – the first one the current time and the second one the desired time. All times will have the format: 1 or 2-digit hour; followed by a colon; followed by a 2-digit minute; followed by “am” or “pm”. A single space will separate the two times. Output Your program should produce one line of output for each problem using one of two formats: ”Going from 7:30am to 7:33am requires 3 pushes.” or “Going from 7:30am to 7:20am requires 1 push.” Sample Input 6 7:30am 7:30am 7:30am 7:33am 7:30am 7:20am 7:30am 7:27am 7:30am 7:30pm 7:10am 7:50am Sample Output Going from 7:30am to 7:30am requires 0 pushes. Going from 7:30am to 7:33am requires 3 pushes. Going from 7:30am to 7:20am requires 1 push. Going from 7:30am to 7:27am requires 4 pushes. Going from 7:30am to 7:30pm requires 1 push. Going from 7:10am to 7:50am requires 2 pushes.
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
使用 Docker 部署 Spring Boot 项目
Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下。首先构建一个简单的 S...
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
干货,2019 RESTful最贱实践
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
文章有点长并且绕,先来个图片缓冲下! 前言 现在的业务场景越来越复杂,使用的架构也就越来越复杂,分布式、高并发已经是业务要求的常态。像腾讯系的不少服务,还有CDN优化、异地多备份等处理。 说到分布式,就必然涉及到分布式锁的概念,如何保证不同机器不同线程的分布式锁同步呢? 实现要点 互斥性,同一时刻,智能有一个客户端持有锁。 防止死锁发生,如果持有锁的客户端崩溃没有主动释放锁,也要保证锁可以正常释...
项目中的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 进程负责处...
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
一、前言 在可视化化程序设计的今天,借助于集成开发环境可以很快地生成程序,程序设计不再是计算机专业人员的专利。很多人认为,只要掌握几种开发工具就可以成为编程高手,其实,这是一种误解。要想成为一个专业的开发人员,至少需要以下三个条件: 1) 能够熟练地选择和设计各种数据结构和算法 2) 至少要能够熟练地掌握一门程序设计语言 3) 熟知所涉及的相关应用领域的知识 其中,后两个条件比较容易实现,而第一个...
Android 9.0 init 启动流程
阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android本篇文章主要介绍Android开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:一、启动流程概述一、 启动流程概述Android启动流程跟Linux启动类似,大致分为如下五个阶段。1.开机上电,加载固化的ROM。2.加载BootLoader,拉起Android OS。3.加载Uboot,初始外设,引导Kernel启动等。...
相关热词 c# clr dll c# 如何orm c# 固定大小的字符数组 c#框架设计 c# 删除数据库 c# 中文文字 图片转 c# 成员属性 接口 c#如何将程序封装 16进制负数转换 c# c#练手项目