ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Count Digits

Count the decimal digits of a positive integer.

Count how many decimal digits n has when written normally, without leading zeros.

Implement count_digits(n).

Input

n: A positive integer.

Output

Return the number of digits.

เงื่อนไข

1 ≤ n ≤ 10¹⁸

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
n = 352

ผลลัพธ์ที่คาดหวัง:
expected = 3
อินพุต:
long long n = 352;

ผลลัพธ์ที่คาดหวัง:
long long expected = 3;
อินพุต:
long n = 352;

ผลลัพธ์ที่คาดหวัง:
long expected = 3;

คำอธิบาย

352 has three digits.

ตัวอย่างที่ 2
อินพุต:
n = 7

ผลลัพธ์ที่คาดหวัง:
expected = 1
อินพุต:
long long n = 7;

ผลลัพธ์ที่คาดหวัง:
long long expected = 1;
อินพุต:
long n = 7;

ผลลัพธ์ที่คาดหวัง:
long expected = 1;

คำอธิบาย

A single digit.

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก