116 条题解
-
22windddos LV 7 @ 2010-04-14 16:17:01
我们设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必胜(以上情况自己考虑)
所以本题和年份完全没关系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'); -
152016-10-21 17:04:01@
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
printf("YES\n");
printf("YES\n");
printf("YES\n");
printf("NO\n");
printf("YES\n");
printf("NO\n");
printf("YES\n");
printf("NO\n");
printf("NO\n");
printf("YES\n");
printf("YES\n");
printf("NO\n");
printf("YES\n");
printf("NO\n");
printf("NO\n");
printf("NO\n");
printf("NO\n");
printf("NO\n");
printf("NO\n");
printf("NO\n");
printf("YES\n");
printf("NO\n");
printf("YES\n");
printf("YES\n");
printf("NO\n");
return 0;
} -
22017-11-26 13:44:01@
#include<iostream> #define py printf("YES\n") #define pn printf("NO\n") using namespace std; int a,b,c,n,stop=0; int main() { scanf("%d",&n); while(n--) { scanf("%d%d%d",&a,&b,&c); if((b==9&&c==30)||(b==1&&c==30)||((b+c)%2==0))py; else pn; } return 0; }
-
02015-09-16 20:46:16@
program exercise(input,output);
var i,j,k,l,m:longint;
f:array[1900..2020,1..12,1..31]of boolean;
function day(x,y:longint):longint;
begin
if (y=1)or(y=3)or(y=5)or(y=7)or(y=8)or(y=10)or(y=12) then
exit(31);
if y>2 then
exit(30);
if (x mod 400=0)or((x mod 100>0)and(x mod 4=0)) then
exit(29);
exit(28);
end;
begin
fillchar(f,sizeof(f),true);
f[2001,11,4]:=false;
f[2001,11,2]:=false;
for i:=2001 downto 1900 do
for j:=12 downto 1 do
begin
if (i=2001)and((j=12)or(j=11)) then
continue;
l:=day(i,j);
for k:=l downto 1 do
begin
if k+1<=l then
f[i,j,k]:=f[i,j,k+1]
else
if j+1<=12 then
f[i,j,k]:=f[i,j+1,1]
else
f[i,j,k]:=f[i+1,1,1];
if j<12 then
f[i,j,k]:=f[i,j,k] and f[i,j+1,k]
else
f[i,j,k]:=f[i,j,k] and f[i+1,1,k];
f[i,j,k]:=not f[i,j,k];
end;
end;
readln(m);
for i:=1 to m do
begin
readln(j,k,l);
if (j<=2001)and(k<=12)and(l<=day(j,k))and(f[j,k,l]) then
writeln('YES')
else
writeln('NO');
end;
end. -
02015-09-16 20:44:19@
program exercise(input,output);
var i,j,k,l,m:longint;
f:array[1900..2020,1..12,1..31]of boolean;
function day(x,y:longint):longint;
begin
if (y=1)or(y=3)or(y=5)or(y=7)or(y=8)or(y=10)or(y=12) then
exit(31);
if y>2 then
exit(30);
if (x mod 400=0)or((x mod 100>0)and(x mod 4=0)) then
exit(29);
exit(28);
end;
begin
fillchar(f,sizeof(f),true);
f[2001,11,4]:=false;
f[2001,11,2]:=false;
for i:=2001 downto 1900 do
for j:=12 downto 1 do
begin
if (i=2001)and((j=12)or(j=11)) then
continue;
l:=day(i,j);
for k:=l downto 1 do
begin
if k+1<=l then
f[i,j,k]:=f[i,j,k+1]
else
if j+1<=12 then
f[i,j,k]:=f[i,j+1,1]
else
f[i,j,k]:=f[i+1,1,1];
if j<12 then
f[i,j,k]:=f[i,j,k] and f[i,j+1,k]
else
f[i,j,k]:=f[i,j,k] and f[i+1,1,k];
f[i,j,k]:=not f[i,j,k];
end;
end;
readln(m);
for i:=1 to m do
begin
readln(j,k,l);
if (j<=2001)and(k<=12)and(l<=day(j,k))and(f[j,k,l]) then
writeln('YES')
else
writeln('NO');
end;
end. -
02015-08-03 15:36:18@
#include<iostream>
using namespace std;
int main()
{
int k;
cin>>k;
for(int i=1;i<=k;i++)
{
int y,m,d;
cin>>y>>m>>d;
if(m==9 && d==30) cout<<"YES"<<endl;
else if(m==1 && d==30) cout<<"YES"<<endl;
else if((m+d)%2==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
} -
02014-12-30 15:42:45@
#include<iostream>
using namespace std;
int main()
{
int k,y,m,d;
cin>>k;
while(k--)
{
cin>>y>>m>>d;
if((m+d)%2==0||(d==30&&(m==1||m==9)))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
} -
02014-11-02 17:37:06@
#include<iostream>
using namespace std;
main()
{
int d,k,m,y;
cin>>k;
while(k--)
{
cin>>y>>m>>d;
if(m==9&&d==30)
cout<<"YES\n";
else
if(m==1&&d==30)
cout<<"YES\n";
else
if(!((m+d)%2))
cout<<"YES\n";
else
cout<<"NO\n";}
} -
02014-08-19 09:36:30@
#include <cstdio>
using namespace std;
int main()
{
int k;scanf("%d", &k);
while (k--)
{
int y, m, d;
scanf("%d %d %d", &y, &m, &d);
if (m == 9 && d == 30)
printf("YES\n");
else if (m == 1 && d == 30)
printf("YES\n");
else if ((m + d) % 2 == 0)
printf("YES\n");
else
printf("NO\n");
}return 0;
} -
02014-05-03 23:23:52@
小心:_2001年11月4日_是错的,其实是__2006年11月4日__……希望管理员能早点改过来
-
02014-03-03 21:38:54@
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <time.h>
#include <string.h>using namespace std;
struct time{
int year;
int month;
int day;
};struct time a[100];
int p[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int r[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};int ren(int a)
{
if(a%100==0 && a%400!=0)
{
return 0;
}
if(a%4==0)
{
return 1;
}
return 0;
}int frist(struct time &a)
{
a.day++;
if((a.month==1 && a.day>31)||(a.month==3 && a.day>31)||(a.month==5 && a.day>31)||
(a.month==7 && a.day>31)||(a.month==8 && a.day>31)||(a.month==10 && a.day>31)||
(a.month==12 && a.day>31))
{
a.day=1;
a.month++;
if(a.month>12)
{
a.month=1;
a.year++;
}
}
else if((a.month==4 && a.day>30)||(a.month==6 && a.day>30)||(a.month==9 && a.day>30)||
(a.month==11 && a.day>30))
{
a.day=1;
a.month++;
}
else if((a.month==2 && a.day>29 && ren(a.year)==1)||
(a.month==2 && a.day>28 && ren(a.year)==0))
{
a.month++;
a.day=1;
}
return 0;
}int second(struct time &a)
{
a.month++;
if(a.month>12)
{
a.month=1;
a.year++;
}
if(ren(a.year)==0)
{
if(a.day>p[a.month])
{
a.day=p[a.month];
// a.month++;
/* if(a.month>12)
{
a.month=1;
a.year++;
}
/
}
}
else
{
if(a.day>r[a.month])
{
a.day=r[a.month];
/ a.month++;
if(a.month>12)
{
a.month=1;
a.year++;
}
*/
}
}
return 0;
}int main(int argc,char *argv[])
{
int i,j,k,n;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i].year>>a[i].month>>a[i].day;
}
for(i=0;i<n;i++)
{
// cout<<i<<endl;
k=0;
while(a[i].year<=2006)
{
frist(a[i]);
if(a[i].year==2006 && a[i].month==11 && a[i].day==4)
{
cout<<"YES"<<endl;
k=1;
break;
}
else
{
second(a[i]);
if(a[i].year==2006 && a[i].month==11 && a[i].day==4)
{
cout<<"NO"<<endl;
k=1;
break;
}
}
}
if(k==0)
cout<<"NO"<<endl;
}
system("pause");
return 0;
}
为什么不能AC -
02013-08-31 14:03:59@
-
02013-05-22 17:09:07@
谁先将日期变到2001.11.4谁就赢了。
应该是
谁先将日期变到2006.11.4谁就赢了。
哇,太无耻了!!!
害我WA好几次
记忆搜索
const
mon:array[1..12]of longint= (31,28,31,30,31,30,31,31,30,31,30,31);
var
f:array[1900..2007,1..12,1..31]of 0..2;
i,j,k,m,n,y,d:longint;
function run(y:Longint):boolean;
begin
if ((y mod 4=0)and(y mod 100<>0))or(y mod 400=0) then exit(true);
exit(false);
end;
function search(y,m,d:Longint):longint;
var
a,b:Longint;
begin
if m>12 then
begin
inc(y);
m:=1;
end;
if (m<>2)or((m=2)and (not run(y)))then
if d>mon[m] then
begin
inc(m);
d:=1;
end
else
else
if d>mon[m]+1 then
begin
inc(m);
d:=1;
end;if m>12 then
begin
inc(y);
m:=1;
end;
if (y>2006)or((y=2006)and(m>11))or((y=2006)and(m=11)and(d>4)) then exit(1);
if f[y,m,d]<>0 then exit(f[y,m,d]);
a:=1;
if (mon[m mod 12 +1]>=d) then a:=search(y,m+1,d);
b:=search(y,m,d+1);
if (a=2)or(b=2) then f[y,m,d]:=1 else f[y,m,d]:=2;
exit(f[y,m,d]);end;
begin
fillchar(f,sizeof(f),0);
f[2006,11,4]:=2;
read(n);
for i:=1 to n do
begin
read(y,m,d);if search(y,m,d)=1 then writeln('YES')
else
writeln('NO');end;
end. -
02012-08-24 16:41:35@
1900写成1990,害我交了5次全出WA!!!!
-
02010-04-10 12:38:58@
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 -
02010-04-07 19:48:05@
虽然看不懂数学方法,但还是。。。。。。
-
02010-03-14 17:12:35@
是不是先操作,拥有主动权,然后就讨论11.4左右天数为30的月份;其余再用奇偶判断。
哪位神牛能解释清楚不??? -
02009-11-08 12:29:06@
记忆化搜索 这里是 关于两种增加方法的边界和月份年份改变判断问题的核心代码
if day[a,b,c]0 then exit(day[a,b,c]);if runnian(a) then t:=2 else t:=1;
if (b=12) then t2:=try1(a+1,1,c) else if (c>m[t,b+1])then t2:=1 else t2:=try1(a,b+1,c);
if (b=12)and(c+1>m[t,b]) then t1:=try1(a+1,1,1) else if (c+1>m[t,b]) then t1:=try1(a,b+1,1) else t1:=try1(a,b,c+1);if (t1=1)and(t2=1) then begin day[a,b,c]:=2;exit(2) end else begin day[a,b,c]:=1;exit(1) end;
无语
编译通过...
├ 测试数据 01:运行超时|格式错误...
---|---|---|---|---|---|---|---|-
Unaccepted 有效得分:0 有效耗时:0ms
这个是边读边写编译通过...
├ 测试数据 01:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
这个是存下来一起写
靠 竟然让我交5次
事实证明 和年份没关系。 -
02009-11-08 10:33:14@
奇偶性解法太难想了,常规解法还是递推
Flag Accepted
题号 P1004
类型(?) 模拟
通过 1450人
提交 4870次
通过率 30%
难度 2 -
02009-11-07 15:10:54@
奇偶性解法真的太神奇了
不过一组数据似乎不太好