主题:[讨论]显示星期几,zjut1124,一直WA...
小小宇宙
[专家分:30] 发布于 2010-07-26 12:43:00
http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1124
用[url=http://hi.baidu.com/pez1420/blog/item/60e364ca8ea2324cf21fe7e1.html]基姆拉尔森计算公式[/url]写的,测试数据都过了,可还是WA。请指点下。
[code=c]
#include <stdio.h>
#include <string.h>
#define M 10000
int main()
{
char s1[][5]={"Mon.","Tue.","Wed.","Thu.","Fri","Sat.","Sun."};
char s[M][5];
int y,m,d;
int i,w,n,n1=0;
scanf("%d\n",&n);
while (n--)
{
scanf("\n%d-%d-%d",&y,&m,&d);
if (m==1||m==2)
{
y--;
m+=12;
}
w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) % 7;
strcpy(s[n1],s1[w]);
n1++;
}
for (i=0;i<n1;i++)
puts(s[i]);
return 0;
}
[/code]
最后更新于:2010-07-26 12:47:00
回复列表 (共4个回复)
沙发
cgl_lgs [专家分:21040] 发布于 2010-07-26 14:42:00
如果测试数据超过10000呢?
你完全可以计算一条输出一条的啊,存那么多条干嘛啊?
难道要求必须是屏幕输出么?
板凳
小小宇宙 [专家分:30] 发布于 2010-07-26 20:50:00
M改成100000也还是不行。
还有,
题目要求是一次性读取全部数据吧……
不过问题应该不在于这里吧……
下面是及时输出的代码,还是WA……[em71][em71][em71][em71][em71]
[code=c]
#include <stdio.h>
#include <string.h>
#define M 10000
int main()
{
char s1[][5]={"Mon.","Tue.","Wed.","Thu.","Fri","Sat.","Sun."};
//char s[M][5];
int y,m,d;
int i,w,n,n1=0;
scanf("%d\n",&n);
while (n--)
{
scanf("\n%d-%d-%d",&y,&m,&d);
if (m==1||m==2)
{
y--;
m+=12;
}
w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) % 7;
puts(s1[w]);
//strcpy(s[n1],s1[w]);
//n1++;
}
//for (i=0;i<n1;i++)
//puts(s[i]);
return 0;
}
[/code]
3 楼
xingxing01 [专家分:0] 发布于 2010-07-27 15:54:00
As some [url=http://www.toppowerlevel.net]wow power leveling[/url] of you may have heard on other sites, such as WoW.com, Blizzard and Upper Deck are not renewing the contract for Upper [url=http://www.mogxe.com/PowerLevel.php?gid=1]wow power leveling[/url] Deck to produce the trading card game cards. This is a big change as Upper Deck [url=http://www.toppowerlevel.net/powerlist.php?fid=688]wow power leveling[/url] is one the biggest distributors of TCG that I can think of. Blizzard [url=http://www.mogxe.com]wow power leveling[/url] has said they will continue forward with the TCG and are continuing to [url=http://www.mogxe.com/PowerLevel.php?gid=21]aion power level[/url] look forward.
Now onto a little speculation! From what [url=http://www.mogxe.com/PowerLevel.php?gid=21]aion powerleveling[/url] I noticed and have heard about around the water cooler (You didn't know we had a water cooler?) is [url=http://www.mogxe.com/BuyGold.php?gid=1]buy wow gold[/url] that Blizzard likes to do things in-house. Compared to when Blizzard [url=http://www.mogxe.com/BuyGold.php?gid=21]aion kinah[/url] and Upper Deck first launched the WoW TCG, Blizzard has received a lot of experience in the [url=http://www.toppowerlevel.net/powerlist.php?fid=7422]aion power level[/url] TCG arena and they may have decided it's time to bring the project under their own umbrella. This would mean Blizzard would begin printing the cards and distributing it themselves and would have more freedom in how to handle things.
4 楼
moke9 [专家分:30] 发布于 2010-09-02 07:33:00
你好.我是全职网赚工作者.
如果你有时间有电脑.
想在网络上创业.请联系我..
项目绝对真实.详情QQ空间资料
加盟请联系 QQ908889846
我来回复