荔园在线

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

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


发信人: alec (AlecMonkeyKing), 信区: ACMICPC
标  题: Re: 值得深思的一道题~
发信站: 荔园晨风BBS站 (Wed May 12 14:50:36 2004), 站内信件

use the matrix to solve this problem is really perfect
but i think it is not easy to think out in the contest
and do not necessarily for this problem
use serach to solve this problem just need about
O=4^9=262144
no more than 10^7
our computer can solved it in 1/10 seconds.
and the serach is much more easy to think
i think it can save a lot of time for the contest
anyway your method is quite good
use the inverse matrix wisely
btw:keep on doing, you will be strong soon
our team need you!
【 在 kaman (天外飞仙) 的大作中提到: 】
: 虽然死搜还是可以通过,但是程序的复杂度和花的时间还是很多的
: 可以用数学的方法,线性代数中的求逆矩阵~
: 我写了一个,特意把它弄烦点~
: 程序如下:
: #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;
: }


--
Alec

※ 修改:·alec 於 May 12 14:54:06 修改本文·[FROM: 61.144.235.39]
※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 61.144.235.39]


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

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