HDU 1536 SG函式應用

2022-07-12 19:33:18 字數 1104 閱讀 7160

只要構造好sg函式

就行:ac**:

#includeusing

namespace

std;

#include

int a[110

],k; //k為全域性變數

int sg[10010],flag[110

];void sg() //

sg函式

}}int

main()

if(s)cout<<"w"

;

else

cout

<<"l"

; }

cout

<}

return0;

}

一開始無限wa,還沒找到錯在哪,就是構造sg函式稍微不同,測試資料和上面的一樣,sg函式資料也一樣,但一直沒ac,有哪位大牛看到錯誤幫忙指點錯在哪,未ac代碼如下:

#includeusing

namespace

std;

#include

#include

#define m 10010

int a[110],b[110],d[110

];int

c[m];

void fun(int a,int k) //

構造 sprague-grundy函式

for(j=0;j)

if(ibreak

;

for(m=0;m)

d[k1++]=c[i-a[m]];

sort(d,d+k1);//

將其排序

for(m=0;;m++)

if(m!=d[m])

}

}int

main()

if(s)cout<<"w"

;

else

cout

<<"l"

; }

printf("\n

");}

return0;

}

hdu 1536 SG函式的應用

hdu 1536 submit time judge status pro.id exe.time exe.memory code len.language 2013 07 24 10 17 33 accepted 1536 109ms 476k 1174 b c include includeus...

HDU 1536 SG函式模板

題目 多堆石子,先手勝為l,後手勝為w,思路 sg函式 sg i 0表示先手必敗,否則必勝 有多堆石子,每次對sg k 的值亦或 最終為0則必敗,否則必勝 include include include include include include include include include ...

hdu 1536 博弈SG函式

1 include 2 include 3 include 4 include 5 include 6 include 7 include 8 include 9 10using namespace std 1112 const int max 109 13 int num max sg max 1...