计算pow(10,9)C ++ [英] Calculate pow(10, 9) C++
问题描述
以下代码问题问题 - A - Codeforces [ ^ ]
我的代码产生错误输出
测试用例(5):10 7
需要一个可被7整除的10位数字。
我的尝试:
for the following codeforces problem Problem - A - Codeforces[^]
My code produces a wrong output on
Test case (5) : 10 7
required a 10-digit-number divisible by 7 .
What I have tried:
int main(){
int n, t;
cin >> n >> t;
if(n == 1 && t == 10)
cout << "-1";
if(t == 10)
cout << 10 * pow(10,n-2);
else
cout << t * pow(10,n-1) << endl ;
return 0;
}
pow(7,9)的输出是(7e + 009)
这个符号是什么意思?
这是C ++中pow(,)的缺点还是我滥用它?
NB我知道另一个解决方案是在数字或输出7777777777之后打印连接的零。我希望固定到我的解决方案并发现更多的pow(,)。
The output from pow(7, 9) is (7e+009)
what does this symbols mean ?
Is this a drawback of pow(,) in C++ or it's me that misused it ?
N.B. I know another solution would be to print zeroes concatenated after the number or output 7777777777 . I want fixation to my solution and discover pow(,) more.
推荐答案
你的代码是乱七八糟的。使用缩进和括号来澄清它。
输出是格式化数字和计算结果。使用变量作为结果和调试器。
Your code is a mess and buggy. Use indention and braces to clarify it.
The output is a formatted number and the result of the calculation. Use variables for results and the debugger.
这篇关于计算pow(10,9)C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!