Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OK brute force DISCSHOP https://www.codechef.com/problems/DISCSHOP
- # include <iostream>
- # include <cmath>
- using namespace std;
- int main() {
- size_t t;
- cin >> t;
- for (size_t i = 0; i < t; i++) {
- size_t n;
- cin >> n;
- size_t res = n;
- size_t k = 1;
- int32_t count = to_string(n).length();
- while (count -- > 0) {
- size_t left = n / (k * 10);
- size_t right = n % k;
- size_t cur = left * k + right;
- k *= 10;
- res = min(res, cur);
- }
- cout << res << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement