裂变

迷失深林的鹿 2021-02-04 12:12:47
大佬们,这种题的解题思路是什么,我想定义平方自增循环可以吗
...全文
227 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
迷失深林的鹿 2021-02-04
  • 打赏
  • 举报
回复
引用 1 楼 qybao的回复:
这题目要求不是很清晰了吗? 输入一个正数n,然后判断n的多少次方才大于等于10000 00000,这个多少次方就是解。 比如一个人最多传给8个人,要传给100个人,那么, 第一次,传给8个人,也就是8的1次方 第二次,这8个人每个人再传给另外8个人,也就是8*8=64=8的平方,此时只有64个人知道,还不满足100个人,所以需要继续传播 第三次,这64个人每个人再传给另外8个人,也就是64*8=512=8的立方,此时有512个人知道,满足100个人,所以需要传播3次 代码例子 int main() { int n, m, p, q; scanf(“%d%d”, &n, &m); for(q=1, p=n; p<m; q++, p*=n); printf(“需要传播%d次”, q); return 0; }
啊!懂了,谢谢❤️
迷失深林的鹿 2021-02-04
  • 打赏
  • 举报
回复
引用 5 楼 赵4老师的回复:
ceil的意思是天花板 Floating-Point Support Many Microsoft run-time library functions require floating-point support from a math coprocessor or from the floating-point libraries that accompany the compiler. Floating-point support functions are loaded only if required. When you use a floating-point type specifier in the format string of a call to a function in the printf or scanf family, you must specify a floating-point value or a pointer to a floating-point value in the argument list to tell the compiler that floating-point support is required. The math functions in the Microsoft run-time library handle exceptions the same way that the UNIX V math functions do. The Microsoft run-time library sets the default internal precision of the math coprocessor (or emulator) to 64 bits. This default applies only to the internal precision at which all intermediate calculations are performed; it does not apply to the size of arguments, return values, or variables. You can override this default and set the chip (or emulator) back to 80-bit precision by linking your program with LIB/FP10.OBJ. On the linker command line, FP10.OBJ must appear before LIBC.LIB, LIBCMT.LIB, or MSVCRT.LIB. Floating-Point Functions Routine Use abs Return absolute value of int acos Calculate arccosine asin Calculate arcsine atan, atan2 Calculate arctangent atof Convert character string to double-precision floating-point value Bessel functions Calculate Bessel functions _j0, _j1, _jn, _y0, _y1, _yn _cabs Find absolute value of complex number ceil Find integer ceiling _chgsign Reverse sign of double-precision floating-point argument _clear87, _clearfp Get and clear floating-point status word _control87, _controlfp Get old floating-point control word and set new control-word value _copysign Return one value with sign of another cos Calculate cosine cosh Calculate hyperbolic cosine difftime Compute difference between two specified time values div Divide one integer by another, returning quotient and remainder _ecvt Convert double to character string of specified length exp Calculate exponential function fabs Find absolute value _fcvt Convert double to string with specified number of digits following decimal point _finite Determine whether given double-precision floating-point value is finite floor Find largest integer less than or equal to argument fmod Find floating-point remainder _fpclass Return status word containing information on floating-point class _fpieee_flt Invoke user-defined trap handler for IEEE floating-point exceptions _fpreset Reinitialize floating-point math package frexp Calculate exponential value _gcvt Convert floating-point value to character string _hypot Calculate hypotenuse of right triangle _isnan Check given double-precision floating-point value for not a number (NaN) labs Return absolute value of long ldexp Calculate product of argument and 2 to specified power ldiv Divide one long integer by another, returning quotient and remainder log Calculate natural logarithm log10 Calculate base-10 logarithm _logb Extract exponential value of double-precision floating-point argument _lrotl, _lrotr Shift unsigned long int left (_lrotl) or right (_lrotr) _matherr Handle math errors __max Return larger of two values __min Return smaller of two values modf Split argument into integer and fractional parts _nextafter Return next representable neighbor pow Calculate value raised to a power printf, wprintf Write data to stdout according to specified format rand Get pseudorandom number _rotl, _rotr Shift unsigned int left (_rotl) or right (_rotr) _scalb Scale argument by power of 2 scanf, wscanf Read data from stdin according to specified format and write data to specified location sin Calculate sine sinh Calculate hyperbolic sine sqrt Find square root srand Initialize pseudorandom series _status87, _statusfp Get floating-point status word strtod Convert character string to double-precision value tan Calculate tangent tanh Calculate hyperbolic tangent
谢谢老师,虽然只能看懂一部分
qybao 2021-02-04
  • 打赏
  • 举报
回复
这题目要求不是很清晰了吗? 输入一个正数n,然后判断n的多少次方才大于等于10000 00000,这个多少次方就是解。 比如一个人最多传给8个人,要传给100个人,那么, 第一次,传给8个人,也就是8的1次方 第二次,这8个人每个人再传给另外8个人,也就是8*8=64=8的平方,此时只有64个人知道,还不满足100个人,所以需要继续传播 第三次,这64个人每个人再传给另外8个人,也就是64*8=512=8的立方,此时有512个人知道,满足100个人,所以需要传播3次 代码例子 int main() { int n, m, p, q; scanf(“%d%d”, &n, &m); for(q=1, p=n; p<m; q++, p*=n); printf(“需要传播%d次”, q); return 0; }
赵4老师 2021-02-04
  • 打赏
  • 举报
回复
ceil的意思是天花板 Floating-Point Support Many Microsoft run-time library functions require floating-point support from a math coprocessor or from the floating-point libraries that accompany the compiler. Floating-point support functions are loaded only if required. When you use a floating-point type specifier in the format string of a call to a function in the printf or scanf family, you must specify a floating-point value or a pointer to a floating-point value in the argument list to tell the compiler that floating-point support is required. The math functions in the Microsoft run-time library handle exceptions the same way that the UNIX V math functions do. The Microsoft run-time library sets the default internal precision of the math coprocessor (or emulator) to 64 bits. This default applies only to the internal precision at which all intermediate calculations are performed; it does not apply to the size of arguments, return values, or variables. You can override this default and set the chip (or emulator) back to 80-bit precision by linking your program with LIB/FP10.OBJ. On the linker command line, FP10.OBJ must appear before LIBC.LIB, LIBCMT.LIB, or MSVCRT.LIB. Floating-Point Functions Routine Use abs Return absolute value of int acos Calculate arccosine asin Calculate arcsine atan, atan2 Calculate arctangent atof Convert character string to double-precision floating-point value Bessel functions Calculate Bessel functions _j0, _j1, _jn, _y0, _y1, _yn _cabs Find absolute value of complex number ceil Find integer ceiling _chgsign Reverse sign of double-precision floating-point argument _clear87, _clearfp Get and clear floating-point status word _control87, _controlfp Get old floating-point control word and set new control-word value _copysign Return one value with sign of another cos Calculate cosine cosh Calculate hyperbolic cosine difftime Compute difference between two specified time values div Divide one integer by another, returning quotient and remainder _ecvt Convert double to character string of specified length exp Calculate exponential function fabs Find absolute value _fcvt Convert double to string with specified number of digits following decimal point _finite Determine whether given double-precision floating-point value is finite floor Find largest integer less than or equal to argument fmod Find floating-point remainder _fpclass Return status word containing information on floating-point class _fpieee_flt Invoke user-defined trap handler for IEEE floating-point exceptions _fpreset Reinitialize floating-point math package frexp Calculate exponential value _gcvt Convert floating-point value to character string _hypot Calculate hypotenuse of right triangle _isnan Check given double-precision floating-point value for not a number (NaN) labs Return absolute value of long ldexp Calculate product of argument and 2 to specified power ldiv Divide one long integer by another, returning quotient and remainder log Calculate natural logarithm log10 Calculate base-10 logarithm _logb Extract exponential value of double-precision floating-point argument _lrotl, _lrotr Shift unsigned long int left (_lrotl) or right (_lrotr) _matherr Handle math errors __max Return larger of two values __min Return smaller of two values modf Split argument into integer and fractional parts _nextafter Return next representable neighbor pow Calculate value raised to a power printf, wprintf Write data to stdout according to specified format rand Get pseudorandom number _rotl, _rotr Shift unsigned int left (_rotl) or right (_rotr) _scalb Scale argument by power of 2 scanf, wscanf Read data from stdin according to specified format and write data to specified location sin Calculate sine sinh Calculate hyperbolic sine sqrt Find square root srand Initialize pseudorandom series _status87, _statusfp Get floating-point status word strtod Convert character string to double-precision value tan Calculate tangent tanh Calculate hyperbolic tangent
迷失深林的鹿 2021-02-04
  • 打赏
  • 举报
回复
引用 3 楼 movsd的回复:
用等比数列求和公式: int n=8,m=1000000000; printf("%d\n",(int)ceil(log((double)m*(n-1)+1)/log((double)n)));
ceil是什么意思啊大佬
movsd 2021-02-04
  • 打赏
  • 举报
回复
用等比数列求和公式: int n=8,m=1000000000; printf("%d\n",(int)ceil(log((double)m*(n-1)+1)/log((double)n)));

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧