回 帖 发 新 帖 刷新版面

主题:菜鸟解超难题,看了别吓着!

cls
Print "1=a,2=b,3=c,4=d,5=e"
print
for d1=1 to 5
for d2=1 to 5
for d3=1 to 5
for d4=1 to 5
for d5=1 to 5
for d6=1 to 5
for d7=1 to 5
for d8=1 to 5
for d9=1 to 5
for d10=1 to 5
p1=0
p2=0
p3=0
p4=0:pa4=0
p5=0
p6=0:pb6=0:pc6=0:pd6=0:pe6=0
p7=0
p8=0:pp8=0
p9=0:pp9=0
if d1=1 then pa4=pa4+1
if d2=1 then pa4=pa4+1
if d3=1 then pa4=pa4+1
if d4=1 then pa4=pa4+1
if d5=1 then pa4=pa4+1
if d6=1 then pa4=pa4+1
if d7=1 then pa4=pa4+1
if d8=1 then pa4=pa4+1
if d9=1 then pa4=pa4+1
if d10=1 then pa4=pa4+1
if d1=2 then pb6=pb6+1
if d2=2 then pb6=pb6+1
if d3=2 then pb6=pb6+1
if d4=2 then pb6=pb6+1
if d5=2 then pb6=pb6+1
if d6=2 then pb6=pb6+1
if d7=2 then pb6=pb6+1
if d8=2 then pb6=pb6+1
if d9=2 then pb6=pb6+1
if d10=2 then pb6=pb6+1
if d1=3 then pc6=pc6+1
if d2=3 then pc6=pc6+1
if d3=3 then pc6=pc6+1
if d4=3 then pc6=pc6+1
if d5=3 then pc6=pc6+1
if d6=3 then pc6=pc6+1
if d7=3 then pc6=pc6+1
if d8=3 then pc6=pc6+1
if d9=3 then pc6=pc6+1
if d10=3 then pc6=pc6+1
if d1=4 then pd6=pd6+1
if d2=4 then pd6=pd6+1
if d3=4 then pd6=pd6+1
if d4=4 then pd6=pd6+1
if d5=4 then pd6=pd6+1
if d6=4 then pd6=pd6+1
if d7=4 then pd6=pd6+1
if d8=4 then pd6=pd6+1
if d9=4 then pd6=pd6+1
if d10=4 then pd6=pd6+1
if d1=5 then pe6=pe6+1
if d2=5 then pe6=pe6+1
if d3=5 then pe6=pe6+1
if d4=5 then pe6=pe6+1
if d5=5 then pe6=pe6+1
if d6=5 then pe6=pe6+1
if d7=5 then pe6=pe6+1
if d8=5 then pe6=pe6+1
if d9=5 then pe6=pe6+1
if d10=5 then pe6=pe6+1
if (d1=1)or(d1=5) then pp8=pp8+1
if (d2=1)or(d2=5) then pp8=pp8+1
if (d3=1)or(d3=5) then pp8=pp8+1
if (d4=1)or(d4=5) then pp8=pp8+1
if (d5=1)or(d5=5) then pp8=pp8+1
if (d6=1)or(d6=5) then pp8=pp8+1
if (d7=1)or(d7=5) then pp8=pp8+1
if (d8=1)or(d8=5) then pp8=pp8+1
if (d9=1)or(d9=5) then pp8=pp8+1
if (d10=1)or(d10=5) then pp8=pp8+1
if (d1<>1)and(d1<>5) then pp9=pp9+1
if (d2<>1)and(d2<>5) then pp9=pp9+1
if (d3<>1)and(d3<>5) then pp9=pp9+1
if (d4<>1)and(d4<>5) then pp9=pp9+1
if (d5<>1)and(d5<>5) then pp9=pp9+1
if (d6<>1)and(d6<>5) then pp9=pp9+1
if (d7<>1)and(d7<>5) then pp9=pp9+1
if (d8<>1)and(d8<>5) then pp9=pp9+1
if (d9<>1)and(d9<>5) then pp9=pp9+1
if (d10<>1)and(d10<>5) then pp9=pp9+1
  if (d1=1)and(d2=2) then p1=1
  if (d1=3)and(d4=2) then p1=1
  if (d1=4)and(d5=2) then p1=1
  if (d1=5)and(d6=2) then p1=1:if p1<>1 then goto EENDD
   if (d2=1)and(d2=d3) then p2=1
   if (d2=2)and(d3=d4) then p2=1
   if (d2=3)and(d4=d5) then p2=1
   if (d2=4)and(d5=d6) then p2=1
   if (d2=5)and(d6=d7) then p2=1:if p2<>1 then goto EENDD
    if (d3=1)and(d3=d1) then p3=1
    if (d3=2)and(d3=d2) then p3=1
    if (d3=3)and(d3=d4) then p3=1
    if (d3=4)and(d3=d7) then p3=1
    if (d3=5)and(d3=d6) then p3=1:if p3<>1 then goto EENDD
     if d4=pa4+1 then p4=1:if p4<>1 then goto EENDD
      if (d5=1)and(d5=d10) then p5=1
      if (d5=2)and(d5=d9) then p5=1
      if (d5=3)and(d5=d8) then p5=1
      if (d5=4)and(d5=d7) then p5=1
      if (d5=5)and(d5=d6) then p5=1:if p5<>1 then goto EENDD
       if (d6=1)and(pa4=pb6) then p6=1
       if (d6=2)and(pa4=pc6) then p6=1
       if (d6=3)and(pa4=pd6) then p6=1
       if (d6=4)and(pa4=pe6) then p6=1
       if (d6=5)and(pa4<>pb6)and(pa4<>pc6)and(pa4<>pd6)and(pa4<>pe6) then p6=1:if p6<>1 then goto EENDD
        if (d7=1)and(d8=5) then p7=1
        if (d7=2)and(d8=5) then p7=1
        if (d7=3)and((d8=1)or(d8=5)) then p7=1
        if (d7=4)and((d8=3)or(d8=5)) then p7=1
        if (d7=5)and(d8=5) then p7=1:if p7<>1 then goto EENDD
         if (d8=1)and(pp8=2) then p8=1
         if (d8=2)and(pp8=3) then p8=1
         if (d8=3)and(pp8=4) then p8=1
         if (d8=4)and(pp8=5) then p8=1
         if (d8=5)and(pp8=6) then p8=1:if p8<>1 then goto EENDD
          if (d9=1)and((pp9=2)or(pp9=3)or(pp9=5)or(pp9=7)) then p9=1
          if (d9=2)and((pp9=1)or(pp9=2)or(pp9=6)) then p9=1
          if (d9=3)and((pp9=1)or(pp9=4)or(pp9=9)) then p9=1
          if (d9=4)and((pp9=1)or(pp9=8)) then p9=1
          if (d9=5)and((pp9=5)or(pp9=10)) then p9=1:if p9<>1 then goto EENDD
if (p1=1)and(p2=1)and(p3=1)and(p4=1)and(p5=1)and(p6=1)and(p7=1)and(p8=1)and(p9=1) then
    if ((d1=d2)and(d2<>d3)and(d3<>d4)and(d4<>d5)and(d5<>d6)and(d6<>d7)and(d7<>d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2=d3)and(d3<>d4)and(d4<>d5)and(d5<>d6)and(d6<>d7)and(d7<>d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3=d4)and(d4<>d5)and(d5<>d6)and(d6<>d7)and(d7<>d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3<>d4)and(d4=d5)and(d5<>d6)and(d6<>d7)and(d7<>d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3<>d4)and(d4<>d5)and(d5=d6)and(d6<>d7)and(d7<>d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3<>d4)and(d4<>d5)and(d5<>d6)and(d6=d7)and(d7<>d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3<>d4)and(d4<>d5)and(d5<>d6)and(d6<>d7)and(d7=d8)and(d8<>d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3<>d4)and(d4<>d5)and(d5<>d6)and(d6<>d7)and(d7<>d8)and(d8=d9)and(d9<>d10))or_
       ((d1<>d2)and(d2<>d3)and(d3<>d4)and(d4<>d5)and(d5<>d6)and(d6<>d7)and(d7<>d8)and(d8<>d9)and(d9=d10)) then_
       print d1;d2;d3;d4;d5;d6;d7;d8;d9;d10
EENDD:end if
next
next
next
next
next
next
next
next
next
next

回复列表 (共15个回复)

沙发

记得以前 MOZ 给出了以下题的解法:
1、第一个答案是b的问题是哪一个?
(a)2;(b) 3;(c)4;(d)5;(e)6
2、!唯一!的连续两个具有相同答案的问题是:
(a)2,3;(b)3,4;(c)4,5;(d)5,6;(e)6,7;
 3、本问题答案和哪一个问题的答案相同?
(a)1;(b)2;(c)4;(d)7;(e)6  
4、答案是a的问题的个数是:
(a)0;(b)1;(c)2;(d)3;(e)4 
5、本问题答案和哪一个问题的答案相同? 
(a)10;(b)9;(c)8;(d)7;(e)6  
6、答案是a的问题的个数和答案是什么的问题的个数相同?
 (a)b;(b)c;(c)d;(d)e;(e)以上都不是 
7、按照字母顺序,本问题的答案和下一个问题的答案相差几个字母?
 (a)4;(b)3;(c)2;(d)1;(e)0。(注:a和b相差一个字母)
8、答案是元音字母的问题的个数是:
(a)2;(b)3;(c)4;(d)5;(e)6。(注:a和e是元音字母) 
9、答案是辅音字母的问题的个数是:
  (a)一个质数;(b)一个阶乘数;(c)一个平方数;(d)一个立方数,(e)5的倍数  
10、本问题的答案是:
    (a)a;(b)b;(c)c;(d)d;(e)e。

然后。。现在。我学了两个语句 :循环和条件语句
 然后。。。我。。。就 试了一试 看看我。。的能力有多强????
   妈呀,,,,大家 帮我看看呀,,,哪里能改进。。或者有什么建议

  请大家 提出来啊!!

板凳

你试试结果对不对不就得了,
只要思路对,结果对,那就行了.
不过我没办法验证,
因为我的QB放不了续行符.

3 楼

我运行后的结果是正确的。。。
  不过。。。速度太慢了!!!!计算机算了6分钟啊!!!!!T_T
  不知道有没有办法。。。。加速。。。可能关键在循环上。。?

4 楼

关键在条件判断上

5 楼

条件判断。。。??不会是用 or  把一些合并吧?? 我觉得这样速度 不会大幅度提高啊。。。。
    我试了一下 
for d1=1 to 5
for d2=1 to 5
for d3=1 to 5
for d4=1 to 5
for d5=1 to 5
for d6=1 to 5
for d7=1 to 5
for d8=1 to 5
for d9=1 to 5
for d10=1 to 5
 print d1;d2;d3;d4;d5;d6;d7;d8;d9;d10
next
next
next
next
next
next
next
next
next
next
      都用了 好长时间才。。。显示完。。。T_T

  不知道 循环这里 能改进不???

6 楼

没必要这么大的工程把?你在编写超做系统吗???

7 楼

只想用自己的方法解上面的题而已~~

8 楼

什么题目竟然用10层循环?

物理模型,到数学模型的过程一定要有简化,不可照搬。

数学模型到程序,注意算法的选择。

9 楼

我是初学者  对楼上的听不懂啊~~~ 不知道 楼上能否讲解?

10 楼

有病,你真有时间.

我来回复

您尚未登录,请登录后再回复。点此登录或注册