The problem description S01 string is initially " 0 " Transform 0 Change to 01 input format 1 integers (0~ +) output format N-transform S01 String Sample input 3 Sample Output 101 data size and conventions 0~Remember:The information given by the topic is misleading, so people can't see the law (1 should be "1")The specific requirements are obtained by looking at the results of the test data (Lll¬ω¬)That is: the string of n = (n-1 string) + (N-2 string)AC Code:1#include 2 #defineMAX 100103 4 /*de
The problem description enters a sequence of 10 integers that requires ascending sorting and removes duplicate elements. Enter a format of 10 integers. Output format multiple lines of output, one element per line. Sample input 2233115555 Sample Output 1235Problem Solving Ideas:If the input number exists in the array, it is excluded, otherwise the storageSort from small to large, and outputAC Code:1#include 2 #defineMAX 103 4 intMainvoid)5 {6 inti =0, j =0, k =0;7 intarr[max+1];8 fo
Algorithm training Delete Array 0 element time limit: 1.0s memory limit: 512.0MB Reads n integers from the keyboard into the array, writes the function compactintegers, deletes all elements with a value of 0 in the array, and then moves the elements to the first end of the array. Note that the Compactintegers function needs to accept the array and its number of elements as arguments, and the function return value should be the number of new elements of the array after the delete operation execut
); + A System.out.println (maxsum); at } - /** - * Maximum and - * @paramRow number of rows - * @paramarr Array - * @returnthe path of the maximum and in */ - Private Static intMaxsum (intRowint[] arr) { to for(inti = row-2; I >= 0; i--){ + for(intj = 0; J ){ -ARR[I][J] + = Maxnum (arr[i+1][j), arr[i+1][j+1]); the } * } $ returnArr[0][0];Panax Notoginseng } - the /** + * Find the maximum numbe
+ intm = y-2 > 0? y-2:0;//the starting position of the Emperor's column range ax = x > n-1? N-1: x;//the end position of the Emperor's line range aty = y > n-1? N-1: y;//the end position of the Emperor column range - -Column_num =New int[n]; -Palace =New int[n][n]; - - for(inti = k; I //Emperor Range-1 in for(intj = m; J ){ -palace[i][j] = 1; to } + } - thePlace (0); * $System.out.println (count);//number of o
((src.charat (k) = = ' + ' | | | Src.charat (k) = = '-') (temp.length ()! = 0)) the break; the the temp.append (src.charat (k));94 Src.deletecharat (k); the } the they =integer.parseint (temp.tostring ());98Temp.delete (0, Temp.length ()); about - Switch(OP) {101 case+:102sum = x +y;103Src.deletecharat (k-1);//Delete operator104Src.insert (k-1, sum + "");//the result is stored in the operator position of SRC (the numbe
Algorithm training 4-3 Daffodils number time limit: 1.0s memory Limit: 256.0MB problem description Print all daffodils between 100 and 999. The so-called Narcissus number refers to the number of cubes that satisfy them and the integers for the number itself, such as 153=1^3+5^3+3^3. Sample input An input example that satisfies the requirements of the topic.Cases:No sample output 153XxxXxxTopic Analysis:This is a simple problem of brute force cracking. Simply break down the hundred, 10, and digit
Algorithm training 6-1 Recursive two-term coefficient value time limit: 10.0s memory Limit: 256.0MB problem Description Sample Enter an input example that satisfies the requirements of the topic.3 10 Sample output corresponds to the output of the sample input above.Data size and convention the range of each number in the input data.Example: The result does not overflow when int is represented.Topic Analysis:for recursive problems, we pay attention to two points: (1) Find the exit; (2) Find simil
Algorithm training Narcissus time limit: 1.0s memory limit: 256.0MB Narcissus number problem description judge giventhree-digit numberWhether Narcissus number. The so-called Narcissus number refers to its value equal to its own number of cubic meters per digit. Example 153 is a number of daffodils. 153=13+53+33 an integer in the input format. Output format is narcissus number, output "YES", otherwise output "no" (not including quotation marks) sample input 123 sample output no data size and conv
use the sort () function, directly using the Arrays.sort () function array of small to large order, each time the results are directly output.At the same time, I need to clear the results after the loop, I use the Arrays.fill () function, with ' "" to fill, but there are insufficient places, will be emptied after the form of 0 exist, the length of the array has not changed, so need me to further improve, the final evaluation results still have a run timeout!! , for informational purposes onlyIn
; * /*output the entire string in reverse order*/ $ Case 3:Panax Notoginseng for(i = strlen (arr)-1; I >=0; I--) - { theprintf"%c", Arr[i]); + } A Break; the /*converts the corresponding uppercase letter in a string to lowercase letters, lowercase to uppercase*/ + Case 4: - for(i =0; I ) $ { $ if(Arr[i] >='A' Arr[i] 'Z') - { -Arr[i] + = +; the
"Idea": vector perfect solution. Notice the dynamic array of vectors, or else 0."AC Code":#include Blue Bridge Cup ALGO-111 random number (sort, go weight)
Remember:The wording of printf ("%*s%s%*s\n", N-i, "", Arr,n-i, "") is used here,where the * in%*s represents the number of the string s, S is given to the string,This is usually used for printing.AC Code:1#include 2 #defineMAX 503 4 intMainvoid)5 {6 intI,n;7 Chararr[max+1];8scanf"%d",n);9sprintf (arr,"%s","*");Ten for(i =1; I ) One { Aprintf"%*s%s%*s\n", N-i,"", Arr,n-i,""); -sprintf (arr,"%s%s", arr,"**"); - } the - return 0; -}
much or not clear, and then on the Internet to learn from the great God code, just understand how.1#include 2#include 3#include 4 using namespacestd;5 structnode{6 ints,e,v;7}edge[100010];8 intm=0, n,val[10010],p;9 voidAddintSintEintv) {Tenedge[++m].s=s; OneEdge[m].e=e; Aedge[m].v=v; - } - intfather[10010]; the intFINDF (inti) {//and check set, intends to use Kruskal to calculate the minimum spanning tree; - if(father[i]==i)returni; - Else returnfather[i]=findf (Father[i]); - } + BO
Algorithm training friendly number time limit: 1.0s memory limit: 256.0MB The problem description has two integers, and if the approximate sum of each integer is equal to the other (except for itself), we call this logarithm friendly. For example:9 Approximate and have: 1+3=44 Approximate and have: 1+2=3So 9 and 4 are not friendly.220 approximate and With: 1 2 4 5 10 11 20 22 44 55 110=284284 Approximate and With: 1 2 4 71 142=220So 220 and 284 are friendly.Write a program to determine whether t
"Ideas": Use of Atoi and itoa, note atoi, three parameters. The first one is the number to convert, the second is the one that is stored in that string, and the third is what the binary is. "AC Code":#include Blue Bridge Cup ALGO-93 inverse number (math, function)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.