Hdoj sort (call value and return value type of POW function)

Source: Internet
Author: User
Tags pow

Note : ThePOW function is contained in the header file math.h, and the POW (A, A, A, b) represents the power of a. The call and return values of the POW function are floating-point,

Both double N=pow (double a,double b) or float N (float a,float b).

Examples:

SortTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 36580 Accepted Submission (s): 10362


Problem description Enter a line of numbers, if we take this line of the number of ' 5 ' as a space, then we get a line with a space separated by a number of non-negative integers (some integers may start with ' 0 ', these headers ' 0 ' should be ignored, unless the integer is a number of ' 0 ', then this integer is 0).

Your task is to sort the output from small to large for these segmented integers.


Input inputs contain multiple sets of test cases, each set of input data with only one row of numbers (no spaces between the numbers), and the length of the line number is not greater than 1000.

Input data Assurance: The resulting non-negative integers are not greater than 100000000, and the input data cannot be composed of ' 5 '.

Output for each test case, the result of an integer ordering of the outputs is divided by a single space between the adjacent two integers, one row for each set of outputs.

Sample Input
0051231232050775

Sample Output
0 77 12312320

This problem also took a lot of time, the first is the error in the algorithm, and then the POW function type error.

The code is as follows:


#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include < Algorithm>using namespace Std;int main () {int l,len,i,j,t,k;double A[1100],b[1100];char str[1100];while (scanf ("%s" , str)!=eof) {memset (a,0,sizeof (a)); Memset (b,0,sizeof (b)); j=0;t=0; L=strlen (str); for (i=0;i<l;i++) {if (str[i]== ' 5 ' &&i==0)//Handle the case of the first number 5    continue;if (str[i]== ' 5 ' & &str[i-1]== ' 5 ')//processing has a continuous 5 occurrences    continue;if (str[i]== ' 5 ')//processing encounters 5 o'clock to save 5 front numbers into the array b[t]; {for (k=0;k<j;k++) {b[t]=b[t]+ (A[k]*pow (10*1.0, (j-1-k) *1.0),//pow type and Writing}j=0;memset (A,0,sizeof (a)); t++; Continue;} a[j++]=str[i]-' 0 '; if (str[i]!= ' 5 ' &&i==l-1)//processing the last number is not 5 case {for   (k=0;k<j;k++) {b[t]=b[t]+ (A[k]*pow (10*1.0, (j-1-k) *1.0));} j=0;t++;}} Sort (b,b+t);p rintf ("%.0LF", b[0]);//Note the output is of type double, do not output decimal for (i=1;i<t;i++)  printf ("%.0LF", B[i]);p rintf ("\ n" );} return 0;}


Hdoj sort (call value and return value type of POW function)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.