ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: northwolves

[推荐] 提供800个题目大家做做

[复制链接]

TA的精华主题

TA的得分主题

发表于 2017-4-13 15:27 | 显示全部楼层
留个脚印,学习了。

TA的精华主题

TA的得分主题

发表于 2017-4-13 15:40 | 显示全部楼层
Problem 1207 - average number of different buses

Thelma drives shuttle buses.  There are 60 of them in the yard numbered 1 to 60. Each day that she works she is randomly assigned a bus.  After 40 days of working, on average how many different buses has she driven?  For example:  If she just happened to be assigned bus number 9 each of her 40 days then she will have only driven one bus, or if she just happened to be assigned bus number 9 or bus number 3 on each of her 40 days she will have driven only 2 different buses.
Round your answer to 2 decimal places.
Solution Format/Example: 15.37

问题1207:平均开过几辆不同的公车?

某公交线路有60个司机60台车编号1-60、每天随机驾驶其中1台车。
问40天内,平均每个司机开过几辆不同编号的公车?

答案=29.37

我写了两种解法,第2种计算精度高一点。

  1. Sub test1()
  2.     Dim i&, j&, m&, n&, r&, s&
  3.     m = 60: n = 40
  4.    
  5.     For i = 0 To 10 ^ 4 - 1
  6.         ReDim a(m - 1)
  7.         For j = 1 To n
  8.             r = Int(Rnd * m)
  9.             a(r) = a(r) + 1
  10.         Next
  11.         
  12.         For j = 0 To m - 1
  13.             If a(j) Then s = s + 1
  14.         Next
  15.     Next
  16.     Debug.Print s / i
  17.     Stop
  18. End Sub

  19. Sub test2()
  20.     Dim i&, j&, k&, m&, n&, r&, s&
  21.     m = 60: n = 80
  22.     ReDim a(m - 1)
  23.     For i = 0 To m - 1
  24.         a(i) = i
  25.     Next
  26.    
  27.     For i = 0 To 10 ^ 3 - 1
  28.         ReDim b(m - 1, m - 1)
  29.         Randomize
  30.         For k = 1 To n
  31.             For j = 0 To m - 1
  32.                 r = Int(Rnd * (m - j)) + j
  33.                 t = a(r): a(r) = a(j): a(j) = t: b(j, t) = b(j, t) + 1
  34.             Next
  35.         Next
  36.         
  37.         For j = 0 To m - 1
  38.             For k = 0 To m - 1
  39.                 If b(j, k) Then s = s + 1
  40.             Next
  41.         Next
  42.     Next
  43.     Debug.Print s / m / i
  44.     Stop
  45. End Sub
复制代码

TA的精华主题

TA的得分主题

发表于 2017-4-13 16:35 | 显示全部楼层
Problem 1199 - Fair Chance

You and your friend are flipping coins, but on the next toss instead of flipping a coin you decide to randomly select a number between 0 and N inclusively. If the chosen random number has 5 as any of its digits your friend wins, otherwise you win. What should the number N be so as to allow each of you a 50% chance to win this game and make it fair? There are multiple numbers N that fit this criteria, what is the smallest?

Second question: once the number N is chosen you convince your friend that since all digits are pretty evenly distributed it won't matter what digit you are looking for, and instead of looking for 5 you want to look for digit X. So when a random number is chosen between 0 and N inclusively if it contains X as any of its digits your friend wins otherwise you win. What should the digit X be to skew the game most in your favor?

Submit your answer separated by a comma: N, X
Solution Format/Example: 493, 7

问题1199 - 公平猜数:

你和你的朋友喜欢玩扔硬币,但这次你们决定随机选择0到N范围内的一个数字。
如果选择的随机数任何数位上含有5,那么你的朋友赢了,否则你就赢了。
N数应该是多少能让你们每个人都有50%的机会赢得这场比赛,这公平吗?
可能有多个数字N,符合这一标准的最小的N是什么?

第二个问题:一旦N选择好之后,你欺骗说服你的朋友,说我们另外定一个数字x,如果随机选择的0-N范围内的数中任意位上含有X那么你的朋友赢了否则你赢了。数字X应该选什么可以使得该游戏对你最有利?

回答格式由一个逗号分开:N,X
例子:493,7

答案:590489,0

  1. Sub test4()
  2.     Do
  3.         n = n + 1
  4.         If InStr(n, 5) Then m = m + 1: If m > n \ 2 Then Debug.Print n: Exit Do
  5.     Loop
  6. End Sub
复制代码


TA的精华主题

TA的得分主题

发表于 2017-4-24 22:37 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-19 02:20 , Processed in 0.036385 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表