1702A - Round Down the Price - CodeForces Solution


constructive algorithms *800

Please click on ads to support us..

Python Code:

def f(m):
    k = 0

    while 10 ** k <= m:
        k += 1

    return k - 1

t = int(input())

ans = []

for i in range(t):
    m = int(input())

    ans.append(m - 10 ** f(m))


for i in ans:
    print(i)

C++ Code:

#include <bits/stdc++.h>
using namespace std;
long long int count(long long int n){
    int cnt=0;
    while(n>0){
        cnt++;
        n=n/10;
    }
    return cnt;
}

int main() {
  long long int t;
   cin>>t;
   while(t--){
       long long int n;
       cin>>n;
     long long  int a=count(n);
     long long int h=pow(10,a-1);
       cout<<n-h<<endl;
   }
}


Comments

Submit
0 Comments
More Questions

1668A - Direction Change
1667B - Optimal Partition
1668B - Social Distance
88B - Keyboard
580B - Kefa and Company
960A - Check the string
1220A - Cards
897A - Scarborough Fair
1433B - Yet Another Bookshelf
1283B - Candies Division
1451B - Non-Substring Subsequence
1408B - Arrays Sum
1430A - Number of Apartments
1475A - Odd Divisor
1454B - Unique Bid Auction
978C - Letters
501B - Misha and Changing Handles
1496A - Split it
1666L - Labyrinth
1294B - Collecting Packages
1642B - Power Walking
1424M - Ancient Language
600C - Make Palindrome
1669D - Colorful Stamp
1669B - Triple
1669A - Division
1669H - Maximal AND
1669E - 2-Letter Strings
483A - Counterexample
3C - Tic-tac-toe