# LeetCode - 1663. Smallest String With A Given Numeric Value ### 題目網址:https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/ ###### tags: `LeetCode` `Medium` ```cpp= /* -LeetCode format- Problem: 1663. Smallest String With A Given Numeric Value Difficulty: Medium by Inversionpeter */ class Solution { public: string getSmallestString(int n, int k) { k -= n; int zs = k / 25; k %= 25; n -= zs + (k > 0); return string(n, 'a') + (k ? string(1, 'a' + k) : "") + string(zs, 'z'); } }; ```