简体   繁体   English

为什么我的程序对此程序给出“错误答案”?

[英]Why is my program giving “Wrong Answer” for this program?

I was solving this question in Hackerrank and matched the result in my IDE. 我在Hackerrank中解决了这个问题,并在我的IDE中匹配了结果。 But then the answer is not being accepted by Hackerrank. 但是,答案并没有被Hackerrank接受。

My code is: 我的代码是:

for i in range(1,int(raw_input())):
    print (str(i)*i)  

Please help... 请帮忙...

Snapshot of the solution displayed by the Online judge 在线裁判显示的解决方案快照

The task says: 任务说:

Can you do it using only arithmetic operations, a single for loop and print statement? 您可以仅使用算术运算,单个for循环和print语句来完成此操作吗?

Use no more than two lines. 使用不超过两行。 The first line (the for statement) is already written for you. 第一行(for语句)已经为您编写。 You have to complete the print statement. 您必须完成打印声明。

Note: Using anything related to strings will give a score of 0. 注意:使用与字符串相关的任何东西都将得到0分。

This is clear, you cannot use str(i) . 这很清楚,您不能使用str(i)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM