0% found this document useful (0 votes)
68 views2 pages

Problem - 1593B - Codeforces

The document describes a problem from a programming contest on Codeforces. The problem asks for the minimum number of steps to make a positive integer divisible by 25 by removing digits. It provides examples and constraints on the input and guarantees an answer exists for all test cases. It also specifies the input and output formats.

Uploaded by

RITESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views2 pages

Problem - 1593B - Codeforces

The document describes a problem from a programming contest on Codeforces. The problem asks for the minimum number of steps to make a positive integer divisible by 25 by removing digits. It provides examples and constraints on the input and guarantees an answer exists for all test cases. It also specifies the input and output formats.

Uploaded by

RITESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

4/1/24, 8:58 AM Problem - 1593B - Codeforces

|
riteshnub | Logout
You have +385! Wow!

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

00:00:03

Codeforces Round 748 (Div. 3)


Finished
B. Make it Divisible by 25
time limit per test: 1 second Practice
memory limit per test: 256 megabytes
input: standard input
output: standard output
→ Virtual participation 
It is given a positive integer n. In 1 move, one can select any single digit and remove it (i.e.
Virtual contest is a way to take part in past
one selects some position in the number and removes the digit located at this position). The contest, as close as possible to participation
operation cannot be performed if only one digit remains. If the resulting number contains on time. It is supported only ICPC mode for
virtual contests. If you've seen these
leading zeroes, they are automatically removed. problems, a virtual contest is not for you -
solve these problems in the archive. If you
E.g. if one removes from the number 32925 the 3-rd digit, the resulting number will be 3225 . just want to solve some problem from a
contest, a virtual contest is not for you -
If one removes from the number 20099050 the first digit, the resulting number will be 99050 solve this problem in the archive. Never use
(the 2 zeroes going next to the first digit are automatically removed). someone else's code, read the tutorials or
communicate with other person during a
virtual contest.
What is the minimum number of steps to get a number such that it is divisible by 25 and
positive? It is guaranteed that, for each n occurring in the input, the answer exists. It is Start virtual contest
guaranteed that the number n has no leading zeros.

Input → Clone Contest to Mashup 


The first line contains one integer t (1
4
≤ t ≤ 10 ) — the number of test cases. Then t test
cases follow. You can clone this contest to a mashup.

Clone Contest
Each test case consists of one line containing one integer n (25 ≤ n ≤ 1018 ). It is
guaranteed that, for each n occurring in the input, the answer exists. It is guaranteed that the
number n has no leading zeros.
→ Submit?
Output
For each test case output on a separate line an integer k (k ≥ 0) — the minimum number of Language: GNU G++17 7.3.0
steps to get a number such that it is divisible by 25 and positive.
Choose
Choose File No file chosen
file:
Example
input Copy Submit

5
100
71345 → Problem tags
3259
50555 dfs and similar dp greedy math
2050047
math *900
output Copy
No tag edit access
0
3
1 → Contest materials
3
2 Announcement

Note Tutorial
In the first test case, it is already given a number divisible by 25 .

In the second test case, we can remove the digits 1, 3, and 4 to get the number 75 .

In the third test case, it's enough to remove the last digit to get the number 325.

In the fourth test case, we can remove the three last digits to get the number 50 .

In the fifth test case, it's enough to remove the digits 4 and 7.

https://codeforces.com/problemset/problem/1593/B 1/2
4/1/24, 8:58 AM Problem - 1593B - Codeforces

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Apr/01/2024 08:58:14UTC+5.5 (f1).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://codeforces.com/problemset/problem/1593/B 2/2

You might also like