精華區beta Marginalman 關於我們 聯絡資訊
就傻傻的照做 算是比較偏難的easy 比昨天的medium難一點 int getLucky(string s, int k) { int ans = 0; // Transform #1 for(auto c : s) { int ord = c-'a'+1; while(ord>0) { ans += (ord%10); ord /= 10; } } // Transform #2~ for(int i=1; i<k; i++) { int tmp = ans; ans = 0; while(tmp>0) { ans += (tmp%10); tmp /= 10; } } return ans; } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1725323965.A.95C.html
JIWP: 別倦了 09/03 08:40
sustainer123: 大師 09/03 08:42
※ 編輯: DJYOMIYAHINA (125.229.37.69 臺灣), 09/03/2024 08:43:44