Re: [閒聊] 每日leetcode

看板Marginalman作者 (6B)時間7月前 (2025/04/14 01:09), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1394/1548 (看更多)
練習一下shift== using ll = long long; class Solution { public: int countGoodNumbers(long long n) { ll mod = 1e9 + 7; ll cnt = 1; bool even_end = n % 2; ll half = n / 2, mul = 5 * 4; while(half > 0){ if(half & 1) cnt = (cnt * mul) % mod; mul = (mul * mul) % mod; half >>= 1; } if(even_end) cnt = (cnt * 5) % mod; return cnt; } }; 蠻舒服的 左邊一個mul 右邊一個mul ※ 引述《sixB (6B)》之銘言: : 1922. : 看到這個題號就想哈秋哈秋哈秋 : 練習power加速 -- 很姆的咪 姆之咪 http://i.imgur.com/5sw7QOj.jpg
-- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.205.121.194 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1744564170.A.094.html
文章代碼(AID): #1d--_A2K (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1d--_A2K (Marginalman)