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;}