116 条题解
-
0芒果木瓜榴莲 LV 9 @ 2009-11-04 11:10:59
编译通过...
├ 测试数据 01:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msvar n,p,x,y,z:longint;
begin
readln(n);
for p:=1 to n do
begin
readln(x,y,z);
if ((y=9)and(z=30))or((y=11)and(z=30))or(not(odd(y+z)))then writeln('YES') else writeln('NO');
end;
end.奇偶性的题解很好,希望考试的时候能想到
-
02009-10-30 09:19:14@
编译通过...
├ 测试数据 01:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msprogram ex;
const days:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);
var i,j,n:longint;
year:array[1900..2010]of boolean;
f:array[1900..2010,1..12,1..31]of boolean;
rest:array[1..12]of longint;
bo:boolean;procedure check;
var i,j:longint;
begin
fillchar(year,sizeof(year),false);
for i:=1900 to 2010 do
if ((i mod 4=0)and(i mod 1000))or(i mod 400=0) then
year[i]:=true;
end;procedure main;
var i,j,y,m,d,y1,y2,m1,m2,d1,d2,m0,mt:longint;
begin
fillchar(rest,sizeof(rest),0);
fillchar(f,sizeof(f),false);
f[2001,11,3]:=true;
f[2001,11,1]:=true;
for i:=4 to 31 do
if (not odd(i)) then
f[2001,10,i]:=true;
f[2001,10,2]:=true;
for y:=2001 downto 1900 do
begin
if year[y] then rest[2]:=1 else rest[2]:=0;
if y=2001 then m0:=9 else m0:=12;
for m:=m0 downto 1 do
for d:=days[m]+rest[m] downto 1 do
begin
y1:=y;m1:=m;d1:=d+1;
if d1>days[m]+rest[m] then
begin
d1:=1;
inc(m1);
if m1>12 then
begin
m1:=1;
inc(y1);
end;
end;
if m+1>12 then mt:=1 else mt:=m+1;
if days[mt]+rest[mt]>=d then
begin
y2:=y;m2:=m+1;d2:=d;
if m2>12 then
begin
m2:=1;
inc(y2);
end;
end
else
begin
y2:=y1;m2:=m1;d2:=d1;
end;
f[y,m,d]:=(not((f[y1,m1,d1]) and (f[y2,m2,d2])));
end;
end;
end;procedure indoit;
var i,j,x,y,z:longint;
begin
readln(n);
for i:=1 to n do
begin
readln(x,y,z);
if f[x,y,z] then writeln('YES') else writeln('NO');
end;
end;begin
check;
main;
indoit;
end.写完这个。。。 我只想吐血。。。。
看不懂数学方法 所以写了模拟
模拟+状态转移 -
02009-10-24 18:26:50@
编译通过...
├ 测试数据 01:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02009-10-08 11:39:59@
这题数据有问题啊。。。。。
我交程序的时候想到了错误,怎么就A了?
点开一看,哇,只有1个测试点 -
02009-10-06 16:36:09@
过的时候、我很惨烈的笑了。。
-
02009-09-30 23:21:35@
Vijos无敌了~~~`
-
02009-09-27 13:23:37@
...此题...很让人恼火...居然是变到2006.11.4才算赢...
2001.11.4的话,WA...郁闷呐...
感觉我这个代码比较好理解...
就贴了一下...
f[y,m,d]表示此日期是否必胜.
状态转移:f[y,m,d]:=not(f[y,m+1,d] and f[y,m,d+1]);
program voj1004;
const md:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);
var f:array[1900..2010,1..12,1..31]of boolean;
year:array[1900..2010]of boolean;
r:array[1..12]of longint;procedure start;
var i:longint;
begin
fillchar(year,sizeof(year),false);
for i:=1900 to 2010 do
if (i mod 4=0) and not ((i mod 100=0) and (i mod 4000)) then
year[i]:=true;
fillchar(f,sizeof(f),true);
f[2006,11,4]:=false;
f[2006,11,2]:=false;
end;procedure main;
var y,m,d,y1,m1,d1,y2,m2,d2,m0:longint;
begin
for y:=2006 downto 1900 do begin
if year[y] then r[2]:=1 else r[2]:=0;
if y=2006 then m0:=10 else m0:=12;
for m:=m0 downto 1 do
for d:=md[m]+r[m] downto 1 do begin
y1:=y; m1:=m; d1:=d+1;
if d1>md[m]+r[m] then begin
d1:=1; inc(m1);
if m1>12 then begin
m1:=1; inc(y1);
end;
end;
y2:=y; m2:=m+1; d2:=d;
if m2>12 then begin
m2:=1; inc(y2);
end;
f[y,m,d]:=not (f[y1,m1,d1] and f[y2,m2,d2]);
end;
end;
end;procedure writeout;
var i,a,b,c:longint;
begin
readln(i);
for i:=1 to i do begin
readln(a,b,c);
if f[a,b,c] then writeln('YES') else writeln('NO');
end;
end;begin
start;
main;
writeout;
end. -
02009-09-13 22:49:58@
关于奇偶我来解释……
我们设2001.11.4必败,推上去,即2001.10.4和2001.11.3必胜(此时m+d=偶数)再推上去是11.2,10.3,9.3,都是必败(此时m+d=奇数),以此类推……
为什么9.30和11.30例外呢?
因为9.30和11.30月份+1,即10.30和12.30,都是必败局面
这种情况只有在8月与以后出现,为什么大家应该清楚
2.29为奇数,必败
没有2.29,剩2.28和3.1衔接也没问题,都是必胜
12.31必败,1.1必胜(以上情况自己考虑)
所以本题和年份完全没关系 -
02009-09-11 22:29:11@
居然10行!
哪位大牛:
能解释一下(month + day)的奇偶性与题目的递推关系吗? -
02009-09-05 14:40:08@
各位神牛
我只写了10行
AC…… -
02009-08-28 15:32:34@
const
m:array[1..13] of integer=(31,28,31,30,31,30,31,31,30,31,30,31,0);
var
a:array[1..30011231] of byte;
i,j,k,n:longint;
s:string;
year,month,day,g,p,q,x,y,z,get1,get2:longint;
begin
year:=2001; month:=11; day:=4;
for i:=20011105 to 20011231 do
a[i]:=1;
while (year1900) or (month1) or (day1) do
begin
dec(day);
if day=0 then
begin
dec(month);
if month = 0 then
begin
dec(year);
month:=12;
end;
day:=m[month];
if (month=2) and (year mod 4 = 0) then inc(day);
end;
g:=year*10000+month*100+day;
{get1}
y:=month+1;
x:=m[y]; if (y=2) and (year mod 4 = 0) and (year1900) then x:=x+1;
if (y=day) then
get1:=a[year*10000+(month+1)*100+day]
else if (y=13) then
get1:=a[(year+1)*10000+100+day]
else
get1:=1;
{get2}
y:=day+1; x:=month; z:=year;
p:=m[x]; if (year mod 4 = 0) and (x=2) and (year1900) then inc(p);
if p -
02009-08-23 12:43:27@
記住一個很精辟的話
能達到一個必敗態的,必定是必勝態;全部能達到必勝態的,必定是必敗態
-
02009-08-22 16:01:07@
一开始说我存取非法。。。
我的数组从 1900 01 01 到 2001 12 31
居然不够大!!改成 1 ~ 3001 12 31
就过了!~~
AC
const
m:array[1..13] of integer=(31,28,31,30,31,30,31,31,30,31,30,31,0);
var
a:array[1..30011231] of byte;
i,j,k,n:longint;
s:string;
year,month,day,g,p,q,x,y,z,get1,get2:longint;
begin
year:=2001; month:=11; day:=4;
for i:=20011105 to 20011231 do
a[i]:=1;
while (year1900) or (month1) or (day1) do
begin
dec(day);
if day=0 then
begin
dec(month);
if month = 0 then
begin
dec(year);
month:=12;
end;
day:=m[month];
if (month=2) and (year mod 4 = 0) then inc(day);
end;
g:=year*10000+month*100+day;
{get1}
y:=month+1;
x:=m[y]; if (y=2) and (year mod 4 = 0) and (year1900) then x:=x+1;
if (y=day) then
get1:=a[year*10000+(month+1)*100+day]
else if (y=13) then
get1:=a[(year+1)*10000+100+day]
else
get1:=1;
{get2}
y:=day+1; x:=month; z:=year;
p:=m[x]; if (year mod 4 = 0) and (x=2) and (year1900) then inc(p);
if p -
02009-08-21 22:56:28@
//我崩溃了。。。。总是说我超时。。。
#include
using namespace std;
void fun(int *year,int *month,int *day);//变换一次日期
int main()
{
int i,n,y[100],m[100],d[100],x[100]={0};
cin>>n;
for(i=0;i>y[i]>>m[i]>>d[i];
while((y[i]==2006&&m[i]==11&&d[i]==4)==0)
{
fun(&y[i],&m[i],&d[i]);
x[i]++;
}
}
for(i=0;i -
02009-08-14 11:49:38@
var x,y,z,n,i,tot:longint;
p:boolean;
procedure dfs(x,y,z:longint);
begin
if (x -
02009-08-11 19:09:44@
tyr07说
最后两个数据错了?
-
02009-08-03 17:51:13@
如对本题有疑问可以参看我的题解:http://xujieqi.blog.hexun.com/35722312_d.html
-
02009-07-28 23:12:38@
什么啊。。只有第25个数据是NO
-
02009-07-27 23:12:24@
BS高级骗子.
-
02009-07-24 08:58:41@
var c,i,m,n,y:integer;
begin
readln(c);
for i:=1 to c do
begin
readln(y,m,n);
if(m=9)and(n=30)then writeln('YES')
else if (m=11)and(n=30)then writeln('YES')
else if not(odd(m+n))then writeln('YES')
else writeln('NO');
end;
end.
太简单,秒杀!!!