Re: [閒聊] 每日LeetCode

作者: oin1104 (是oin的說)   2023-11-27 14:06:59

想有點久
想出來惹
就是看他後面能接什麼數字就好惹
我成功了
ya
```c
int knightDialer(int n)
{
if(n == 1)return 10;
long long c1 = 1;
long long c2 = 1;
long long c3 = 1;
long long c4 = 1;
long long c6 = 1;
long long c7 = 1;
long long c8 = 1;
long long c9 = 1;
long long c0 = 1;
long long s1 = 0;
long long s2 = 0;
long long s3 = 0;
long long s4 = 0;
long long s6 = 0;
long long s7 = 0;
long long s8 = 0;
long long s9 = 0;
long long s0 = 0;
long long nc = 0;
for(int i = 1 ; i < n ; i++)
{
s0 = c0;
s1 = c1;
s2 = c2;
s3 = c3;
s4 = c4;
s6 = c6;
s7 = c7;
s8 = c8;
s9 = c9;
c1 = (s6 + s8)%1000000007;
c2 = (s7 + s9)%1000000007;
c3 = (s4 + s8)%1000000007;
c4 = (s0 + s3 + s9)%1000000007;
c6 = (s0 + s1 + s7)%1000000007;
c7 = (s2 + s6)%1000000007;
c8 = (s1 + s3)%1000000007;
c9 = (s2 + s4)%1000000007;
c0 = (s4 + s6)%1000000007;
nc = c1+ c2+ c3+ c4+ c6+ c7+ c8+ c9+ c0;
}
int ans = nc%1000000007;
return ans ;
}
```
作者: sustainer123 (caster)   2023-11-27 14:08:00
大師
作者: SydLrio (狂嵐嘴砲)   2023-11-27 14:12:00
大師
作者: JIWP (JIWP)   2023-11-27 14:23:00
大師
作者: ZooseWu (N5)   2023-11-27 14:51:00
你的陣列還給老師了嗎

Links booklink

Contact Us: admin [ a t ] ucptt.com