心靈終結 找規律

2021-07-26 02:43:31 字數 868 閱讀 6705

給你乙個n*m的棋盤,在上面跳馬,走日,然後馬不能互相吃,問你最多可以放多少條馬

分三種情況討論,n=2 or m=1 ,n=2 or m=2,其他。

可以得出規律,自己看程式,很簡單的

var

t,i,j,x:longint;

n,m,ans:int64;

function

max(x,y:longint):longint;

begin

if x>y then

exit(x)

else

exit(y);

end;

begin

readln(t);

ans:=0;

for i:=1

to t do

begin

ans:=0;

readln(n,m);

if (n=1) or (m=1) then

begin

writeln(max(n,m));

continue;

end;

if (n=2) or (m=2) then

begin

x:=max(n,m) mod

4; ans:=ans+max(n,m) div

4*4;

if x=1

then ans:=ans+2

else

if x>1

then ans:=ans+4;

writeln(ans);

continue;

end;

writeln(((n*m+1) div

2));

end;

end.

心靈終結。。。。終結我的心靈。。。。T T

include include include define ll long long const int maxn 20 using namespace std int a maxn maxn ll f ll x int main int t cin t while t ll n,m cin n ...

找規律 遞推

總時間限制 1000ms 記憶體限制 1024kb 描述 火車從始發站 稱為第1站 開出,在始發站上車的人數為a,然後到達第2站,在第2站有人上 下車,但上 下車的人數相同,因此在第2站開出是 即在到達第3 站之前 車上的人數保持為a人。從第3站起 包括第3站 上 下車的人數有一定的規律 上車的人數...

模擬 找規律

現代數學的著名證明之一是georg cantor證明了有理數是可列舉的。他是用下面這一張表來證明這一命題的 1 1 1 2 1 3 1 4 1 5 2 1 2 2 2 3 2 4 3 1 3 2 3 3 4 1 4 2 5 1 我們以z字形給上表的每一項編號。第一項是1 1,然後是1 2,2 1,3...