1 #define _CRT_SECURE_NO_WARNINGS 2 #include <stdio.h> 3 #include <math.h> 4 #include <algorithm> 5 #include <stdlib.h> 6 #include <vector> 7 #include <map> 8 #include <queue> 9 #include <string> 10 #include <iostream> 11 #include <ctype.h> 12 #include <string.h> 13 #include <set> 14 #include <stack> 15 #include<functional> 16 using namespace std; 17 #define Size 105 18 #define maxn 1<<30 19 #define minn 1e-6 20 char str1[Size], str2[Size]; 21 22 int main(){ 23 memset(str1, 0, sizeof(str1)); 24 memset(str2, 0, sizeof(str2)); 25 scanf("%s%s", str1, str2); 26 int len1 = strlen(str1); 27 int len2 = strlen(str2); 28 for (int i = 0; i < 6; i++) 29 { 30 if (str1[i] == ‘\0‘) str1[i] = ‘0‘; 31 if (str2[i] == ‘\0‘) str2[i] = ‘0‘; 32 } 33 str1[6] = str2[6] = 0; 34 /* 35 求loga(b) = log10b/log10a 36 log10b 的近似值是 lenstrb-1+log10(atoi(str2) / 1e5) 后面的那么多位数不用看了 37 */ 38 printf("%d\n", int((log10(atoi(str2) / 1e5) + len2 - 1) / (log10(atoi(str1) / 1e5) + len1 - 1))); 39 //注意是除过以后再取整而不是取整以后再除 40 system("pause"); 41 }