荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: kaman (天外飞仙), 信区: ACMICPC
标  题: Re: 值得深思的一道题~
发信站: 荔园晨风BBS站 (Wed May 12 13:43:20 2004), 站内信件

虽然死搜还是可以通过,但是程序的复杂度和花的时间还是很多的

可以用数学的方法,线性代数中的求逆矩阵~
我写了一个,特意把它弄烦点~
程序如下:
#include<stdio.h>
int main()
{
        int a,b,c,d,e,f,g,h,i;
        int t[10],k,j,o;
        freopen("clocks.in","r",stdin);
        freopen("clocks.out","w",stdout);

                scanf("%d%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h,&i);
                a=a/3%4;
                b=b/3%4;
                c=c/3%4;
                d=d/3%4;
                e=e/3%4;
                f=f/3%4;
                g=g/3%4;
        h=h/3%4;
                i=i/3%4;

t[0]=0;
t[1] = (8+  a+2*b+  c+2*d+2*e  -f+  g  -h    ) % 4 ;
t[2] = (    a+  b+  c+  d+  e+  f+2*g+    2*i) % 4 ;
t[3] = (8+  a+2*b+  c  -d+2*e+2*f      -h+  i) % 4 ;
t[4] = (    a+  b+2*c+  d+  e+      g+  h+2*i) % 4 ;
t[5] = (4+  a+2*b+  c+2*d  -e+2*f+  g+2*h+  i) % 4 ;
t[6] = (  2*a+  b+  c+      e+  f+2*g+  h+  i) % 4 ;
t[7] = (8+  a  -b+    2*d+2*e  -f+  g+2*h+  i) % 4 ;
t[8] = (  2*a+    2*c+  d+  e+  f+  g+  h+  i) % 4 ;
t[9] = (8      -b+  c  -d+2*e+2*f+  g+2*h+  i) % 4 ;
o=0;
for(k=1;k<10;k++)
for(j=1;j<=t[k];j++)
if(o==0)
{
printf("%d",k);
o=1;
}
else
printf(" %d",k);

printf("\n");

return 0;

}

--
Long long ago,there is a hero stand at the edge of the land,a sword in
hand.......
       ︵~`   ╭)                          ▁▁
      ︸ヾ)    (╯                        ▕天外▏
      ゞ7(  ︵  ))                        ▕飞仙▏
       ╰ ︶へ︶╯                          ▔▔
       ヅ╯  ジ〉

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.111.200]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店