Ultraviolet A 113-power of cryptography (Mathematics)

Source: Internet
Author: User

The result cannot exceed the Integer Range. I used the high precision and the second point passed in poj, but I failed to pass through the ultraviolet. Later, I saw a big bull using double directly on the Internet, which is really admirable.

My code:

# Include <stdio. h> # include <string. h> // swap string function void swap_str (char STR []) {int Len = strlen (STR); For (INT I = 0; I <Len/2; I ++) {int TMP = STR [I]; STR [I] = STR [len-i-1]; STR [len-i-1] = TMP ;}} // function for multiplying a large number and an integer (given as a string) void my_mul (char STR [], int X) {int Len = strlen (STR); int CP = 0, i, TMP; swap_str (STR); for (I = 0; I <Len; I ++) {TMP = (STR [I]-'0 ') * x + CP; STR [I] = (TMP % 10) + '0'; CP = tmp/10;} wh Ile (CP) {STR [I ++] = (CP % 10) + '0'; CP/= 10 ;} while ('0' = STR [I-1] & I> 1) I --; STR [I] = '\ 0'; swap_str (STR );} // compare the sizes of two large numbers (not 0 before a large number) int my_numcmp (char str1 [], char str2 []) {int len1, len2; len1 = strlen (str1 ); len2 = strlen (str2); If (len1> len2) return 1; if (len1 <len2) Return-1; return strcmp (str1, str2 );} // string storage open result void my_pow (char STR [], int K, int N) {STR [0] = '1', STR [1] = '\ 0 '; whil E (n --) {my_mul (STR, k) ;}// returns the correct int my_binary_search (int n, char STR []) {int high = 1e9, low = 0; int mid; char tot [1, 2005]; while (low 

Cool code:

#include <stdio.h>#include <math.h>int main() {    double n, p;    while (scanf("%lf%lf", &n, &p) != EOF) {        printf("%.lf\n", pow(p, 1/n));    }    return 0;}

 

 

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.