euler-manager 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/bin/euler +145 -0
- data/data/answers.yml +456 -0
- data/data/problems/1.yml +7 -0
- data/data/problems/10.yml +8 -0
- data/data/problems/100.yml +13 -0
- data/data/problems/101.yml +49 -0
- data/data/problems/102.yml +16 -0
- data/data/problems/103.yml +26 -0
- data/data/problems/104.yml +15 -0
- data/data/problems/105.yml +21 -0
- data/data/problems/106.yml +19 -0
- data/data/problems/107.yml +20 -0
- data/data/problems/108.yml +32 -0
- data/data/problems/109.yml +33 -0
- data/data/problems/11.yml +33 -0
- data/data/problems/110.yml +19 -0
- data/data/problems/111.yml +21 -0
- data/data/problems/112.yml +15 -0
- data/data/problems/113.yml +13 -0
- data/data/problems/114.yml +106 -0
- data/data/problems/115.yml +17 -0
- data/data/problems/116.yml +76 -0
- data/data/problems/117.yml +82 -0
- data/data/problems/118.yml +9 -0
- data/data/problems/119.yml +11 -0
- data/data/problems/12.yml +13 -0
- data/data/problems/120.yml +17 -0
- data/data/problems/121.yml +15 -0
- data/data/problems/122.yml +42 -0
- data/data/problems/123.yml +13 -0
- data/data/problems/124.yml +58 -0
- data/data/problems/125.yml +12 -0
- data/data/problems/126.yml +17 -0
- data/data/problems/127.yml +31 -0
- data/data/problems/128.yml +18 -0
- data/data/problems/129.yml +12 -0
- data/data/problems/13.yml +6 -0
- data/data/problems/130.yml +19 -0
- data/data/problems/131.yml +12 -0
- data/data/problems/132.yml +12 -0
- data/data/problems/133.yml +13 -0
- data/data/problems/134.yml +19 -0
- data/data/problems/135.yml +20 -0
- data/data/problems/136.yml +17 -0
- data/data/problems/137.yml +36 -0
- data/data/problems/138.yml +20 -0
- data/data/problems/139.yml +15 -0
- data/data/problems/14.yml +28 -0
- data/data/problems/140.yml +29 -0
- data/data/problems/141.yml +14 -0
- data/data/problems/142.yml +14 -0
- data/data/problems/143.yml +20 -0
- data/data/problems/144.yml +30 -0
- data/data/problems/145.yml +11 -0
- data/data/problems/146.yml +9 -0
- data/data/problems/147.yml +14 -0
- data/data/problems/148.yml +11 -0
- data/data/problems/149.yml +41 -0
- data/data/problems/15.yml +11 -0
- data/data/problems/150.yml +34 -0
- data/data/problems/151.yml +19 -0
- data/data/problems/152.yml +12 -0
- data/data/problems/153.yml +57 -0
- data/data/problems/154.yml +16 -0
- data/data/problems/155.yml +22 -0
- data/data/problems/156.yml +27 -0
- data/data/problems/157.yml +34 -0
- data/data/problems/158.yml +19 -0
- data/data/problems/159.yml +29 -0
- data/data/problems/16.yml +6 -0
- data/data/problems/160.yml +8 -0
- data/data/problems/161.yml +15 -0
- data/data/problems/162.yml +15 -0
- data/data/problems/163.yml +19 -0
- data/data/problems/164.yml +8 -0
- data/data/problems/165.yml +32 -0
- data/data/problems/166.yml +15 -0
- data/data/problems/167.yml +17 -0
- data/data/problems/168.yml +13 -0
- data/data/problems/169.yml +10 -0
- data/data/problems/17.yml +11 -0
- data/data/problems/170.yml +16 -0
- data/data/problems/171.yml +13 -0
- data/data/problems/172.yml +6 -0
- data/data/problems/173.yml +12 -0
- data/data/problems/174.yml +20 -0
- data/data/problems/175.yml +21 -0
- data/data/problems/176.yml +9 -0
- data/data/problems/177.yml +16 -0
- data/data/problems/178.yml +9 -0
- data/data/problems/179.yml +10 -0
- data/data/problems/18.yml +21 -0
- data/data/problems/180.yml +34 -0
- data/data/problems/181.yml +7 -0
- data/data/problems/182.yml +35 -0
- data/data/problems/183.yml +27 -0
- data/data/problems/184.yml +18 -0
- data/data/problems/185.yml +22 -0
- data/data/problems/186.yml +28 -0
- data/data/problems/187.yml +16 -0
- data/data/problems/188.yml +10 -0
- data/data/problems/189.yml +15 -0
- data/data/problems/19.yml +12 -0
- data/data/problems/190.yml +13 -0
- data/data/problems/191.yml +15 -0
- data/data/problems/192.yml +27 -0
- data/data/problems/193.yml +7 -0
- data/data/problems/194.yml +18 -0
- data/data/problems/195.yml +13 -0
- data/data/problems/196.yml +25 -0
- data/data/problems/197.yml +16 -0
- data/data/problems/198.yml +21 -0
- data/data/problems/199.yml +14 -0
- data/data/problems/2.yml +10 -0
- data/data/problems/20.yml +22 -0
- data/data/problems/200.yml +12 -0
- data/data/problems/201.yml +20 -0
- data/data/problems/202.yml +14 -0
- data/data/problems/203.yml +21 -0
- data/data/problems/204.yml +11 -0
- data/data/problems/205.yml +10 -0
- data/data/problems/206.yml +6 -0
- data/data/problems/207.yml +20 -0
- data/data/problems/208.yml +12 -0
- data/data/problems/209.yml +27 -0
- data/data/problems/21.yml +13 -0
- data/data/problems/210.yml +10 -0
- data/data/problems/211.yml +11 -0
- data/data/problems/212.yml +41 -0
- data/data/problems/213.yml +11 -0
- data/data/problems/214.yml +15 -0
- data/data/problems/215.yml +18 -0
- data/data/problems/216.yml +14 -0
- data/data/problems/217.yml +27 -0
- data/data/problems/218.yml +14 -0
- data/data/problems/219.yml +19 -0
- data/data/problems/22.yml +13 -0
- data/data/problems/220.yml +24 -0
- data/data/problems/221.yml +20 -0
- data/data/problems/222.yml +7 -0
- data/data/problems/223.yml +12 -0
- data/data/problems/224.yml +12 -0
- data/data/problems/225.yml +11 -0
- data/data/problems/226.yml +16 -0
- data/data/problems/227.yml +13 -0
- data/data/problems/228.yml +23 -0
- data/data/problems/229.yml +30 -0
- data/data/problems/23.yml +19 -0
- data/data/problems/230.yml +23 -0
- data/data/problems/231.yml +16 -0
- data/data/problems/232.yml +14 -0
- data/data/problems/233.yml +10 -0
- data/data/problems/234.yml +23 -0
- data/data/problems/235.yml +9 -0
- data/data/problems/236.yml +32 -0
- data/data/problems/237.yml +13 -0
- data/data/problems/238.yml +42 -0
- data/data/problems/239.yml +9 -0
- data/data/problems/24.yml +10 -0
- data/data/problems/240.yml +11 -0
- data/data/problems/241.yml +17 -0
- data/data/problems/242.yml +16 -0
- data/data/problems/243.yml +19 -0
- data/data/problems/244.yml +32 -0
- data/data/problems/245.yml +36 -0
- data/data/problems/246.yml +17 -0
- data/data/problems/247.yml +21 -0
- data/data/problems/248.yml +6 -0
- data/data/problems/249.yml +7 -0
- data/data/problems/25.yml +15 -0
- data/data/problems/250.yml +7 -0
- data/data/problems/251.yml +13 -0
- data/data/problems/252.yml +31 -0
- data/data/problems/253.yml +36 -0
- data/data/problems/254.yml +21 -0
- data/data/problems/255.yml +59 -0
- data/data/problems/256.yml +43 -0
- data/data/problems/257.yml +18 -0
- data/data/problems/258.yml +13 -0
- data/data/problems/259.yml +16 -0
- data/data/problems/26.yml +11 -0
- data/data/problems/260.yml +30 -0
- data/data/problems/261.yml +19 -0
- data/data/problems/262.yml +20 -0
- data/data/problems/263.yml +19 -0
- data/data/problems/264.yml +20 -0
- data/data/problems/265.yml +16 -0
- data/data/problems/266.yml +10 -0
- data/data/problems/267.yml +14 -0
- data/data/problems/268.yml +8 -0
- data/data/problems/269.yml +15 -0
- data/data/problems/27.yml +25 -0
- data/data/problems/270.yml +17 -0
- data/data/problems/271.yml +13 -0
- data/data/problems/272.yml +15 -0
- data/data/problems/273.yml +21 -0
- data/data/problems/274.yml +23 -0
- data/data/problems/275.yml +19 -0
- data/data/problems/276.yml +11 -0
- data/data/problems/277.yml +24 -0
- data/data/problems/278.yml +32 -0
- data/data/problems/279.yml +6 -0
- data/data/problems/28.yml +17 -0
- data/data/problems/280.yml +13 -0
- data/data/problems/281.yml +17 -0
- data/data/problems/282.yml +10 -0
- data/data/problems/283.yml +11 -0
- data/data/problems/284.yml +22 -0
- data/data/problems/285.yml +17 -0
- data/data/problems/286.yml +12 -0
- data/data/problems/287.yml +36 -0
- data/data/problems/288.yml +15 -0
- data/data/problems/289.yml +19 -0
- data/data/problems/29.yml +24 -0
- data/data/problems/290.yml +8 -0
- data/data/problems/291.yml +10 -0
- data/data/problems/292.yml +13 -0
- data/data/problems/293.yml +15 -0
- data/data/problems/294.yml +10 -0
- data/data/problems/295.yml +26 -0
- data/data/problems/296.yml +15 -0
- data/data/problems/297.yml +19 -0
- data/data/problems/298.yml +46 -0
- data/data/problems/299.yml +31 -0
- data/data/problems/3.yml +7 -0
- data/data/problems/30.yml +12 -0
- data/data/problems/300.yml +24 -0
- data/data/problems/301.yml +25 -0
- data/data/problems/302.yml +18 -0
- data/data/problems/303.yml +11 -0
- data/data/problems/304.yml +19 -0
- data/data/problems/305.yml +14 -0
- data/data/problems/306.yml +29 -0
- data/data/problems/307.yml +12 -0
- data/data/problems/308.yml +34 -0
- data/data/problems/309.yml +17 -0
- data/data/problems/31.yml +18 -0
- data/data/problems/310.yml +19 -0
- data/data/problems/311.yml +21 -0
- data/data/problems/312.yml +15 -0
- data/data/problems/313.yml +17 -0
- data/data/problems/314.yml +29 -0
- data/data/problems/315.yml +49 -0
- data/data/problems/316.yml +25 -0
- data/data/problems/317.yml +11 -0
- data/data/problems/318.yml +61 -0
- data/data/problems/319.yml +23 -0
- data/data/problems/32.yml +14 -0
- data/data/problems/320.yml +12 -0
- data/data/problems/321.yml +18 -0
- data/data/problems/322.yml +12 -0
- data/data/problems/323.yml +19 -0
- data/data/problems/324.yml +17 -0
- data/data/problems/325.yml +25 -0
- data/data/problems/326.yml +12 -0
- data/data/problems/327.yml +39 -0
- data/data/problems/328.yml +36 -0
- data/data/problems/329.yml +17 -0
- data/data/problems/33.yml +13 -0
- data/data/problems/330.yml +40 -0
- data/data/problems/331.yml +28 -0
- data/data/problems/332.yml +16 -0
- data/data/problems/333.yml +25 -0
- data/data/problems/334.yml +39 -0
- data/data/problems/335.yml +16 -0
- data/data/problems/336.yml +24 -0
- data/data/problems/337.yml +15 -0
- data/data/problems/338.yml +41 -0
- data/data/problems/339.yml +17 -0
- data/data/problems/34.yml +7 -0
- data/data/problems/340.yml +14 -0
- data/data/problems/341.yml +18 -0
- data/data/problems/342.yml +17 -0
- data/data/problems/343.yml +29 -0
- data/data/problems/344.yml +21 -0
- data/data/problems/345.yml +26 -0
- data/data/problems/346.yml +11 -0
- data/data/problems/347.yml +16 -0
- data/data/problems/348.yml +12 -0
- data/data/problems/349.yml +13 -0
- data/data/problems/35.yml +8 -0
- data/data/problems/350.yml +18 -0
- data/data/problems/351.yml +13 -0
- data/data/problems/352.yml +49 -0
- data/data/problems/353.yml +25 -0
- data/data/problems/354.yml +16 -0
- data/data/problems/355.yml +8 -0
- data/data/problems/356.yml +10 -0
- data/data/problems/357.yml +9 -0
- data/data/problems/358.yml +31 -0
- data/data/problems/359.yml +26 -0
- data/data/problems/36.yml +8 -0
- data/data/problems/360.yml +12 -0
- data/data/problems/361.yml +20 -0
- data/data/problems/362.yml +32 -0
- data/data/problems/363.yml +33 -0
- data/data/problems/364.yml +15 -0
- data/data/problems/365.yml +17 -0
- data/data/problems/366.yml +26 -0
- data/data/problems/367.yml +20 -0
- data/data/problems/368.yml +39 -0
- data/data/problems/369.yml +15 -0
- data/data/problems/37.yml +10 -0
- data/data/problems/370.yml +16 -0
- data/data/problems/371.yml +13 -0
- data/data/problems/372.yml +16 -0
- data/data/problems/373.yml +10 -0
- data/data/problems/374.yml +25 -0
- data/data/problems/375.yml +23 -0
- data/data/problems/376.yml +25 -0
- data/data/problems/377.yml +11 -0
- data/data/problems/378.yml +15 -0
- data/data/problems/379.yml +15 -0
- data/data/problems/38.yml +18 -0
- data/data/problems/380.yml +22 -0
- data/data/problems/381.yml +21 -0
- data/data/problems/382.yml +23 -0
- data/data/problems/383.yml +13 -0
- data/data/problems/384.yml +28 -0
- data/data/problems/385.yml +22 -0
- data/data/problems/386.yml +16 -0
- data/data/problems/387.yml +19 -0
- data/data/problems/388.yml +12 -0
- data/data/problems/389.yml +12 -0
- data/data/problems/39.yml +10 -0
- data/data/problems/390.yml +18 -0
- data/data/problems/391.yml +29 -0
- data/data/problems/392.yml +22 -0
- data/data/problems/393.yml +12 -0
- data/data/problems/394.yml +22 -0
- data/data/problems/395.yml +19 -0
- data/data/problems/396.yml +28 -0
- data/data/problems/397.yml +20 -0
- data/data/problems/398.yml +13 -0
- data/data/problems/399.yml +22 -0
- data/data/problems/4.yml +8 -0
- data/data/problems/40.yml +18 -0
- data/data/problems/400.yml +18 -0
- data/data/problems/401.yml +11 -0
- data/data/problems/402.yml +25 -0
- data/data/problems/403.yml +19 -0
- data/data/problems/404.yml +21 -0
- data/data/problems/405.yml +15 -0
- data/data/problems/406.yml +46 -0
- data/data/problems/407.yml +20 -0
- data/data/problems/408.yml +14 -0
- data/data/problems/409.yml +12 -0
- data/data/problems/41.yml +8 -0
- data/data/problems/410.yml +19 -0
- data/data/problems/411.yml +23 -0
- data/data/problems/412.yml +19 -0
- data/data/problems/413.yml +13 -0
- data/data/problems/414.yml +40 -0
- data/data/problems/415.yml +19 -0
- data/data/problems/416.yml +13 -0
- data/data/problems/417.yml +21 -0
- data/data/problems/418.yml +17 -0
- data/data/problems/419.yml +22 -0
- data/data/problems/42.yml +14 -0
- data/data/problems/420.yml +13 -0
- data/data/problems/421.yml +29 -0
- data/data/problems/422.yml +22 -0
- data/data/problems/423.yml +22 -0
- data/data/problems/424.yml +37 -0
- data/data/problems/425.yml +16 -0
- data/data/problems/426.yml +29 -0
- data/data/problems/427.yml +18 -0
- data/data/problems/428.yml +32 -0
- data/data/problems/429.yml +10 -0
- data/data/problems/43.yml +17 -0
- data/data/problems/430.yml +20 -0
- data/data/problems/431.yml +33 -0
- data/data/problems/432.yml +13 -0
- data/data/problems/433.yml +18 -0
- data/data/problems/434.yml +32 -0
- data/data/problems/435.yml +21 -0
- data/data/problems/436.yml +21 -0
- data/data/problems/437.yml +22 -0
- data/data/problems/438.yml +29 -0
- data/data/problems/439.yml +17 -0
- data/data/problems/44.yml +16 -0
- data/data/problems/440.yml +21 -0
- data/data/problems/441.yml +23 -0
- data/data/problems/442.yml +9 -0
- data/data/problems/443.yml +13 -0
- data/data/problems/444.yml +28 -0
- data/data/problems/445.yml +37 -0
- data/data/problems/446.yml +29 -0
- data/data/problems/447.yml +31 -0
- data/data/problems/448.yml +14 -0
- data/data/problems/449.yml +17 -0
- data/data/problems/45.yml +15 -0
- data/data/problems/450.yml +26 -0
- data/data/problems/451.yml +15 -0
- data/data/problems/452.yml +8 -0
- data/data/problems/453.yml +16 -0
- data/data/problems/454.yml +17 -0
- data/data/problems/455.yml +16 -0
- data/data/problems/456.yml +15 -0
- data/data/problems/46.yml +18 -0
- data/data/problems/47.yml +21 -0
- data/data/problems/48.yml +7 -0
- data/data/problems/49.yml +10 -0
- data/data/problems/5.yml +8 -0
- data/data/problems/50.yml +10 -0
- data/data/problems/51.yml +15 -0
- data/data/problems/52.yml +8 -0
- data/data/problems/53.yml +28 -0
- data/data/problems/54.yml +43 -0
- data/data/problems/55.yml +21 -0
- data/data/problems/56.yml +11 -0
- data/data/problems/57.yml +15 -0
- data/data/problems/58.yml +22 -0
- data/data/problems/59.yml +23 -0
- data/data/problems/6.yml +13 -0
- data/data/problems/60.yml +10 -0
- data/data/problems/61.yml +30 -0
- data/data/problems/62.yml +9 -0
- data/data/problems/63.yml +7 -0
- data/data/problems/64.yml +130 -0
- data/data/problems/65.yml +62 -0
- data/data/problems/66.yml +27 -0
- data/data/problems/67.yml +17 -0
- data/data/problems/68.yml +23 -0
- data/data/problems/69.yml +14 -0
- data/data/problems/7.yml +6 -0
- data/data/problems/70.yml +16 -0
- data/data/problems/71.yml +17 -0
- data/data/problems/72.yml +16 -0
- data/data/problems/73.yml +16 -0
- data/data/problems/74.yml +41 -0
- data/data/problems/75.yml +16 -0
- data/data/problems/76.yml +8 -0
- data/data/problems/77.yml +8 -0
- data/data/problems/78.yml +12 -0
- data/data/problems/79.yml +11 -0
- data/data/problems/8.yml +6 -0
- data/data/problems/80.yml +11 -0
- data/data/problems/81.yml +19 -0
- data/data/problems/82.yml +19 -0
- data/data/problems/83.yml +23 -0
- data/data/problems/84.yml +63 -0
- data/data/problems/85.yml +9 -0
- data/data/problems/86.yml +15 -0
- data/data/problems/87.yml +12 -0
- data/data/problems/88.yml +53 -0
- data/data/problems/89.yml +18 -0
- data/data/problems/9.yml +13 -0
- data/data/problems/90.yml +23 -0
- data/data/problems/91.yml +19 -0
- data/data/problems/92.yml +29 -0
- data/data/problems/93.yml +21 -0
- data/data/problems/94.yml +11 -0
- data/data/problems/95.yml +23 -0
- data/data/problems/96.yml +46 -0
- data/data/problems/97.yml +14 -0
- data/data/problems/98.yml +16 -0
- data/data/problems/99.yml +16 -0
- data/euler-manager.gemspec +31 -0
- data/euler-manager.sublime-project +12 -0
- data/example/1/README.md +6 -0
- data/example/1/ruby/1.rb +5 -0
- data/example/1/scala/1.scala +9 -0
- data/example/2/README.md +9 -0
- data/example/2/python/2.py +5 -0
- data/example/2/python/euler.py +0 -0
- data/example/Eulerfile.rb +87 -0
- data/example/README.md +26 -0
- data/example/lib/euler.py +0 -0
- data/example/lib/euler.rb +0 -0
- data/example/lib/euler.scala +5 -0
- data/lib/euler.rb +190 -0
- data/lib/euler/errors.rb +7 -0
- data/lib/euler/languages.rb +12 -0
- data/lib/euler/languages/coffeescript.rb +25 -0
- data/lib/euler/languages/javascript.rb +25 -0
- data/lib/euler/languages/python.rb +27 -0
- data/lib/euler/languages/ruby.rb +25 -0
- data/lib/euler/languages/scala.rb +27 -0
- data/lib/euler/languages/templates/coffeescript.coffee +5 -0
- data/lib/euler/languages/templates/javascript.js +5 -0
- data/lib/euler/languages/templates/python.py +5 -0
- data/lib/euler/languages/templates/ruby.rb +5 -0
- data/lib/euler/languages/templates/scala.scala +9 -0
- data/lib/euler/problem.rb +60 -0
- data/lib/euler/solution.rb +98 -0
- data/lib/euler/version.rb +3 -0
- data/scripts/update_problems +68 -0
- data/spec/euler/problem_spec.rb +5 -0
- data/spec/euler/solution_spec.rb +69 -0
- data/spec/euler_spec.rb +27 -0
- data/spec/spec_helper.rb +3 -0
- metadata +644 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
:id: 328
|
3
|
+
:name: Lowest-cost Search
|
4
|
+
:url: http://projecteuler.net/problem=328
|
5
|
+
:content: "\r\n<p>We are trying to find a hidden number selected from the set of integers
|
6
|
+
{1, 2, ..., <var>n</var>} by asking questions. \r\nEach number (question) we ask,
|
7
|
+
has a <u>cost equal to the number asked</u> and we get one of three possible answers:<br></p>\n<ul>\n<li>
|
8
|
+
\"Your guess is lower than the hidden number\", or</li>\r\n<li> \"Yes, that's it!\",
|
9
|
+
or</li>\r\n<li> \"Your guess is higher than the hidden number\".</li>\r\n</ul>\n<p>Given
|
10
|
+
the value of <var>n</var>, an <i>optimal strategy</i> minimizes the total cost (i.e.
|
11
|
+
the sum of all the questions asked) <u>for the worst possible case</u>. E.g.</p>\r\n\r\n<p>If
|
12
|
+
<var>n</var>=3, the best we can do is obviously to ask the number \"<b>2</b>\".
|
13
|
+
The answer will immediately lead us to find the hidden number (at a total cost =
|
14
|
+
2).</p>\r\n\r\n<p>If <var>n</var>=8, we might decide to use a \"binary search\"
|
15
|
+
type of strategy: Our first question would be \"<b>4</b>\" and if the hidden number
|
16
|
+
is higher than 4 we will need one or two additional questions.<br>\r\nLet our second
|
17
|
+
question be \"<b>6</b>\". If the hidden number is still higher than 6, we will need
|
18
|
+
a third question in order to discriminate between 7 and 8.<br>\r\nThus, our third
|
19
|
+
question will be \"<b>7</b>\" and the total cost for this worst-case scenario will
|
20
|
+
be 4+6+7=<span style=\"color:red;\"><b>17</b></span>.</p>\r\n\r\n<p>We can improve
|
21
|
+
considerably the worst-case cost for <var>n</var>=8, by asking \"<b>5</b>\" as our
|
22
|
+
first question.<br>\r\nIf we are told that the hidden number is higher than 5, our
|
23
|
+
second question will be \"<b>7</b>\", then we'll know for certain what the hidden
|
24
|
+
number is (for a total cost of 5+7=<span style=\"color:blue;\"><b>12</b></span>).<br>\r\nIf
|
25
|
+
we are told that the hidden number is lower than 5, our second question will be
|
26
|
+
\"<b>3</b>\" and if the hidden number is lower than 3 our third question will be
|
27
|
+
\"<b>1</b>\", giving a total cost of 5+3+1=<span style=\"color:blue;\"><b>9</b></span>.<br>\r\nSince
|
28
|
+
<span style=\"color:blue;\"><b>12</b></span>><span style=\"color:blue;\"><b>9</b></span>,
|
29
|
+
the worst-case cost for this strategy is <span style=\"color:red;\"><b>12</b></span>.
|
30
|
+
That's better than what we achieved previously with the \"binary search\" strategy;
|
31
|
+
it is also better than or equal to any other strategy.<br>\r\nSo, in fact, we have
|
32
|
+
just described an optimal strategy for <var>n</var>=8.</p>\r\n\r\n<p>Let C(<var>n</var>)
|
33
|
+
be the worst-case cost achieved by an optimal strategy for <var>n</var>, as described
|
34
|
+
above.<br>\r\nThus C(1) = 0, C(2) = 1, C(3) = 2 and C(8) = 12.<br>\r\nSimilarly,
|
35
|
+
C(100) = 400 and <img style=\"vertical-align:middle\" src=\"project/images/p_328_sum1.gif\">C(<var>n</var>)
|
36
|
+
= 17575.</p>\r\n\r\n<p>Find <img style=\"vertical-align:middle\" src=\"project/images/p_328_sum2.gif\">C(<var>n</var>).</p>\r\n"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
:id: 329
|
3
|
+
:name: Prime Frog
|
4
|
+
:url: http://projecteuler.net/problem=329
|
5
|
+
:content: "\r\n<p>Susan has a prime frog.<br>\r\nHer frog is jumping around over 500
|
6
|
+
squares numbered 1 to 500.\r\nHe can only jump one square to the left or to the
|
7
|
+
right, with equal probability, and he cannot jump outside the range [1;500].<br>(if
|
8
|
+
it lands at either end, it automatically jumps to the only available square on the
|
9
|
+
next move.)\r\n</p>\r\n<p>\r\nWhen he is on a square with a prime number on it,
|
10
|
+
he croaks 'P' (PRIME) with probability 2/3 or 'N' (NOT PRIME) with probability 1/3
|
11
|
+
just before jumping to the next square.<br>\r\nWhen he is on a square with a number
|
12
|
+
on it that is not a prime he croaks 'P' with probability 1/3 or 'N' with probability
|
13
|
+
2/3 just before jumping to the next square.\r\n</p>\r\n<p>\r\nGiven that the frog's
|
14
|
+
starting position is random with the same probability for every square, and given
|
15
|
+
that she listens to his first 15 croaks, what is the probability that she hears
|
16
|
+
the sequence PPPPNNPPPNPPNPN?\r\n</p>\r\nGive your answer as a fraction p/q in reduced
|
17
|
+
form.\r\n\r\n"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
:id: 33
|
3
|
+
:name: Digit canceling fractions
|
4
|
+
:url: http://projecteuler.net/problem=33
|
5
|
+
:content: "\r\n<p>The fraction <sup>49</sup>/<sub>98</sub> is a curious fraction,
|
6
|
+
as an inexperienced mathematician in attempting to simplify it may incorrectly believe
|
7
|
+
that <sup>49</sup>/<sub>98</sub> = <sup>4</sup>/<sub>8</sub>, which is correct,
|
8
|
+
is obtained by cancelling the 9s.</p>\r\n<p>We shall consider fractions like, <sup>30</sup>/<sub>50</sub>
|
9
|
+
= <sup>3</sup>/<sub>5</sub>, to be trivial examples.</p>\r\n<p>There are exactly
|
10
|
+
four non-trivial examples of this type of fraction, less than one in value, and
|
11
|
+
containing two digits in the numerator and denominator.</p>\r\n<p>If the product
|
12
|
+
of these four fractions is given in its lowest common terms, find the value of the
|
13
|
+
denominator.</p>\r\n\r\n"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
:id: 330
|
3
|
+
:name: Euler's Number
|
4
|
+
:url: http://projecteuler.net/problem=330
|
5
|
+
:content: "\r\nAn infinite sequence of real numbers <var>a</var>(<var>n</var>) is
|
6
|
+
defined for all integers <var>n</var> as follows:\r\n<div align=\"center\"><img
|
7
|
+
src=\"project/images/p_330_formula.gif\"></div>\r\n\r\n<p>For example,<br></p>\n<table
|
8
|
+
class=\"formula\"><tr>\n<td>\n<var>a</var>(0) = </td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td
|
9
|
+
class=\"overline\">1!</td></tr>\n</table></td>\r\n <td>+</td>\r\n <td><table
|
10
|
+
class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">2!</td></tr>\n</table></td>\r\n
|
11
|
+
\ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">3!</td></tr>\n</table></td>\r\n
|
12
|
+
\ <td>+ ... = e <img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\"
|
13
|
+
alt=\"−\" border=\"0\" style=\"vertical-align:middle;\"> 1 </td>\r\n</tr></table>\n<table
|
14
|
+
class=\"formula\"><tr>\n<td>\n<var>a</var>(1) = </td>\r\n <td><table class=\"frac\">\n<tr><td>e
|
15
|
+
<img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\" alt=\"−\" border=\"0\"
|
16
|
+
style=\"vertical-align:middle;\"> 1</td></tr>\n<tr><td class=\"overline\">1!</td></tr>\n</table></td>\r\n
|
17
|
+
\ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">2!</td></tr>\n</table></td>\r\n
|
18
|
+
\ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">3!</td></tr>\n</table></td>\r\n
|
19
|
+
\ <td>+ ... = 2e <img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\"
|
20
|
+
alt=\"−\" border=\"0\" style=\"vertical-align:middle;\"> 3 </td>\r\n</tr></table>\n<table
|
21
|
+
class=\"formula\"><tr>\n<td>\n<var>a</var>(2) = </td>\r\n <td><table class=\"frac\">\n<tr><td>2e
|
22
|
+
<img src=\"images/symbol_minus.gif\" width=\"9\" height=\"3\" alt=\"−\" border=\"0\"
|
23
|
+
style=\"vertical-align:middle;\"> 3</td></tr>\n<tr><td class=\"overline\">1!</td></tr>\n</table></td>\r\n
|
24
|
+
\ <td>+</td>\r\n <td><table class=\"frac\">\n<tr><td>e <img src=\"images/symbol_minus.gif\"
|
25
|
+
width=\"9\" height=\"3\" alt=\"−\" border=\"0\" style=\"vertical-align:middle;\">
|
26
|
+
1</td></tr>\n<tr><td class=\"overline\">2!</td></tr>\n</table></td>\r\n <td>+</td>\r\n
|
27
|
+
\ <td><table class=\"frac\">\n<tr><td>1</td></tr>\n<tr><td class=\"overline\">3!</td></tr>\n</table></td>\r\n
|
28
|
+
\ <td>+ ... =</td>\r\n <td><table class=\"frac\">\n<tr><td>7</td></tr>\n<tr><td
|
29
|
+
class=\"overline\">2</td></tr>\n</table></td>\r\n <td>e <img src=\"images/symbol_minus.gif\"
|
30
|
+
width=\"9\" height=\"3\" alt=\"−\" border=\"0\" style=\"vertical-align:middle;\">
|
31
|
+
6 </td>\r\n</tr></table>\r\nwith e = 2.7182818... being Euler's constant.\r\n\r\n<p>\r\n</p>\n<table
|
32
|
+
class=\"formula\"><tr>\n<td>It can be shown that <var>a</var>(<var>n</var>) is of
|
33
|
+
the form \r\n </td>\r\n <td><table class=\"frac\">\n<tr><td>A(<var>n</var>)
|
34
|
+
e + B(<var>n</var>)</td></tr>\n<tr><td class=\"overline\">\n<var>n</var>!</td></tr>\n</table></td>\r\n
|
35
|
+
\ <td>for integers A(<var>n</var>) and B(<var>n</var>). \r\n </td>\r\n</tr></table>\n<table
|
36
|
+
class=\"formula\"><tr>\n<td>For example <var>a</var>(10) = \r\n </td>\r\n <td><table
|
37
|
+
class=\"frac\">\n<tr><td>328161643 e <img src=\"images/symbol_minus.gif\" width=\"9\"
|
38
|
+
height=\"3\" alt=\"−\" border=\"0\" style=\"vertical-align:middle;\"> 652694486</td></tr>\n<tr><td
|
39
|
+
class=\"overline\">10!</td></tr>\n</table></td>\r\n <td>.</td>\r\n</tr></table>\n<p>\r\nFind
|
40
|
+
A(10<sup>9</sup>) + B(10<sup>9</sup>) and give your answer mod 77 777 777.\r\n</p>\r\n\r\n\r\n\r\n"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
:id: 331
|
3
|
+
:name: Cross flips
|
4
|
+
:url: http://projecteuler.net/problem=331
|
5
|
+
:content: "\r\n<p><var>N</var><img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
|
6
|
+
alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var> disks are placed
|
7
|
+
on a square game board. Each disk has a black side and white side.</p>\r\n\r\n<p>At
|
8
|
+
each turn, you may choose a disk and flip all the disks in the same row and the
|
9
|
+
same column as this disk: thus 2<img src=\"images/symbol_times.gif\" width=\"9\"
|
10
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>-1
|
11
|
+
disks are flipped. The game ends when all disks show their white side. The following
|
12
|
+
example shows a game on a 5<img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
|
13
|
+
alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">5 board.</p>\r\n\r\n<div
|
14
|
+
align=\"center\"><img src=\"project/images/p_331_crossflips3.gif\"></div>\r\n\r\n<p>It
|
15
|
+
can be proven that 3 is the minimal number of turns to finish this game.</p>\r\n\r\n<p>The
|
16
|
+
bottom left disk on the <var>N</var><img src=\"images/symbol_times.gif\" width=\"9\"
|
17
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>
|
18
|
+
board has coordinates (0,0);<br>\r\nthe bottom right disk has coordinates (<var>N</var>-1,0)
|
19
|
+
and the top left disk has coordinates (0,<var>N</var>-1). </p>\r\n\r\n<p>Let C<sub><var>N</var></sub>
|
20
|
+
be the following configuration of a board with <var>N</var><img src=\"images/symbol_times.gif\"
|
21
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>
|
22
|
+
disks:<br>\r\nA disk at (<var>x</var>,<var>y</var>) satisfying <img style=\"vertical-align:middle\"
|
23
|
+
src=\"project/images/p_331_crossflips1.gif\">, shows its black side; otherwise,
|
24
|
+
it shows its white side. C<sub>5</sub> is shown above.</p>\r\n\r\n<p>Let T(<var>N</var>)
|
25
|
+
be the minimal number of turns to finish a game starting from configuration C<sub><var>N</var></sub>
|
26
|
+
or 0 if configuration C<sub><var>N</var></sub> is unsolvable.<br>\r\nWe have shown
|
27
|
+
that T(5)=3. You are also given that T(10)=29 and T(1 000)=395253.</p>\r\n\r\n<p>Find
|
28
|
+
<img style=\"vertical-align:middle\" src=\"project/images/p_331_crossflips2.gif\">.</p>\r\n\r\n"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
:id: 332
|
3
|
+
:name: Spherical triangles
|
4
|
+
:url: http://projecteuler.net/problem=332
|
5
|
+
:content: "\r\n<p>A <b>spherical triangle</b> is a figure formed on the surface of
|
6
|
+
a sphere by three <b>great circular arcs</b> intersecting pairwise in three vertices.</p>\r\n\r\n<div
|
7
|
+
align=\"center\"><img src=\"project/images/p_332_spherical.jpg\"></div>\r\n\r\n\r\n<p>Let
|
8
|
+
C(<var>r</var>) be the sphere with the centre (0,0,0) and radius <var>r</var>.<br>\r\nLet
|
9
|
+
Z(<var>r</var>) be the set of points on the surface of C(<var>r</var>) with integer
|
10
|
+
coordinates.<br>\r\nLet T(<var>r</var>) be the set of spherical triangles with vertices
|
11
|
+
in Z(<var>r</var>).\r\nDegenerate spherical triangles, formed by three points on
|
12
|
+
the same great arc, are <u>not</u> included in T(<var>r</var>).<br>\r\nLet A(<var>r</var>)
|
13
|
+
be the area of the smallest spherical triangle in T(<var>r</var>).</p>\r\n\r\n<p>For
|
14
|
+
example A(14) is 3.294040 rounded to six decimal places.</p>\r\n\r\n<p>Find <img
|
15
|
+
style=\"vertical-align:middle\" src=\"project/images/p_332_sum.gif\"> A(<var>r</var>).
|
16
|
+
Give your answer rounded to six decimal places.</p>\r\n\r\n"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
:id: 333
|
3
|
+
:name: Special partitions
|
4
|
+
:url: http://projecteuler.net/problem=333
|
5
|
+
:content: "\r\n<p>All positive integers can be partitioned in such a way that each
|
6
|
+
and every term of the partition can be expressed as 2<sup>i</sup>x3<sup>j</sup>,
|
7
|
+
where i,j <img src=\"images/symbol_ge.gif\" width=\"10\" height=\"12\" alt=\"≥\"
|
8
|
+
border=\"0\" style=\"vertical-align:middle;\"> 0.</p>\r\n\r\n<p>Let's consider only
|
9
|
+
those such partitions where none of the terms can divide any of the other terms.\r\n<br>For
|
10
|
+
example, the partition of 17 = 2 + 6 + 9 = (2<sup>1</sup>x3<sup>0</sup> + 2<sup>1</sup>x3<sup>1</sup>
|
11
|
+
+ 2<sup>0</sup>x3<sup>2</sup>) would not be valid since 2 can divide 6. Neither
|
12
|
+
would the partition 17 = 16 + 1 = (2<sup>4</sup>x3<sup>0</sup> + 2<sup>0</sup>x3<sup>0</sup>)
|
13
|
+
since 1 can divide 16. The only valid partition of 17 would be 8 + 9 = (2<sup>3</sup>x3<sup>0</sup>
|
14
|
+
+ 2<sup>0</sup>x3<sup>2</sup>).</p>\r\n\r\n<p>Many integers have more than one valid
|
15
|
+
partition, the first being 11 having the following two partitions.\r\n<br>11 = 2
|
16
|
+
+ 9 = (2<sup>1</sup>x3<sup>0</sup> + 2<sup>0</sup>x3<sup>2</sup>)\r\n<br>11 = 8
|
17
|
+
+ 3 = (2<sup>3</sup>x3<sup>0</sup> + 2<sup>0</sup>x3<sup>1</sup>)</p>\r\n\r\n<p>Let's
|
18
|
+
define P(<var>n</var>) as the number of valid partitions of <var>n</var>. For example,
|
19
|
+
P(11) = 2.</p>\r\n\r\n<p>Let's consider only the prime integers <var>q</var> which
|
20
|
+
would have a single valid partition such as P(17).</p>\r\n\r\n<p>The sum of the
|
21
|
+
primes <var>q</var> <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\"
|
22
|
+
alt=\"<\" border=\"0\" style=\"vertical-align:middle;\">100 such that P(<var>q</var>)=1
|
23
|
+
equals 233.</p>\r\n\r\n<p>Find the sum of the primes <var>q</var> <img src=\"images/symbol_lt.gif\"
|
24
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\">1000000
|
25
|
+
such that P(<var>q</var>)=1.</p>\r\n"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
:id: 334
|
3
|
+
:name: Spilling the beans
|
4
|
+
:url: http://projecteuler.net/problem=334
|
5
|
+
:content: "\r\n<p>In Plato's heaven, there exist an infinite number of bowls in a
|
6
|
+
straight line.<br>\r\nEach bowl either contains some or none of a finite number
|
7
|
+
of beans.<br>\r\nA child plays a game, which allows only one kind of move: removing
|
8
|
+
two beans from any bowl, and putting one in each of the two adjacent bowls.<br>
|
9
|
+
The game ends when each bowl contains either one or no beans.</p>\r\n\r\n<p>For
|
10
|
+
example, consider two adjacent bowls containing 2 and 3 beans respectively, all
|
11
|
+
other bowls being empty. The following eight moves will finish the game:</p>\r\n\r\n<div
|
12
|
+
align=\"center\"><img src=\"project/images/p_334_beans.gif\"></div>\r\n\r\n<p>You
|
13
|
+
are given the following sequences:<br></p>\n<table class=\"formula\" style=\"margin-left:50px;\"><tr>\n<td>\r\n
|
14
|
+
\ <var>t</var><sub><i>0</i></sub> = 123456.\r\n </td>\r\n</tr></table>\n<table
|
15
|
+
class=\"formula\" style=\"margin-left:50px;\">\n<tr>\n<td>\r\n <var>t</var><sub><i>i</i></sub>
|
16
|
+
= \r\n </td>\r\n <td><img src=\"project/images/p_334_cases.gif\"></td>\r\n <td>\r\n
|
17
|
+
\ <table class=\"formula\">\n<tr>\n<td></td>\r\n <td>\r\n <table class=\"frac\">\n<tr><td>\n<var>t</var><sub><i>i-1</i></sub>\n</td></tr>\n<tr><td
|
18
|
+
class=\"overline\">2</td></tr>\n</table>\n</td>\r\n <td>\r\n ,\r\n
|
19
|
+
\ </td>\r\n <td></td>\r\n <td>\r\n if <var>t</var><sub><i>i-1</i></sub>
|
20
|
+
is even\r\n </td>\r\n </tr>\n<tr>\n<td><img src=\"project/images/p_334_lfloor.gif\"></td>\r\n
|
21
|
+
\ <td>\r\n <table class=\"frac\">\n<tr><td>\n<var>t</var><sub><i>i-1</i></sub>\n</td></tr>\n<tr><td
|
22
|
+
class=\"overline\">2</td></tr>\n</table>\n</td>\r\n <td>\r\n <img src=\"project/images/p_334_rfloor.gif\">\n</td>\r\n
|
23
|
+
\ <td>\r\n 926252, \r\n </td>\r\n <td>\r\n if <var>t</var><sub><i>i-1</i></sub>
|
24
|
+
is odd\r\n </td>\r\n </tr>\n</table>\n</td>\n<td>\r\n</td>\n</tr>\n<tr>\n<td></td>\r\n
|
25
|
+
\ <td></td>\r\n <td>\r\n where <img src=\"images/symbol_lfloor.gif\" width=\"6\"
|
26
|
+
height=\"16\" alt=\"⌊\" border=\"0\" style=\"vertical-align:middle;\"><var>x</var><img
|
27
|
+
src=\"images/symbol_rfloor.gif\" width=\"6\" height=\"16\" alt=\"⌋\" border=\"0\"
|
28
|
+
style=\"vertical-align:middle;\"> is the floor function\r\n </td>\r\n</tr>\n<tr>\n<td></td>\r\n
|
29
|
+
\ <td></td>\r\n <td>\r\n and <img src=\"project/images/p_334_oplus.gif\">
|
30
|
+
is the bitwise XOR operator.\r\n </td>\r\n</tr>\n</table>\n<table class=\"formula\"
|
31
|
+
style=\"margin-left:50px;\"><tr>\n<td>\r\n <var>b</var><sub><i>i</i></sub>
|
32
|
+
= ( <var>t</var><sub><i>i</i></sub> mod 2<sup>11</sup>) + 1.\r\n </td>\r\n</tr></table>\n<p>The
|
33
|
+
first two terms of the last sequence are <var>b</var><sub><i>1</i></sub> = 289 and
|
34
|
+
<var>b</var><sub><i>2</i></sub> = 145.<br>\r\nIf we start with <var>b</var><sub><i>1</i></sub>
|
35
|
+
and <var>b</var><sub><i>2</i></sub> beans in two adjacent bowls, 3419100 moves would
|
36
|
+
be required to finish the game.</p>\r\n\r\n<p>Consider now 1500 adjacent bowls containing
|
37
|
+
<var>b</var><sub><i>1</i></sub>, <var>b</var><sub><i>2</i></sub>,..., <var>b</var><sub><i>1500</i></sub>
|
38
|
+
beans respectively, all other bowls being empty. Find how many moves it takes before
|
39
|
+
the game ends.</p>\r\n\r\n\r\n"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
:id: 335
|
3
|
+
:name: Gathering the beans
|
4
|
+
:url: http://projecteuler.net/problem=335
|
5
|
+
:content: "\r\n<p>Whenever Peter feels bored, he places some bowls, containing one
|
6
|
+
bean each, in a circle. After this, he takes all the beans out of a certain bowl
|
7
|
+
and drops them one by one in the bowls going clockwise. He repeats this, starting
|
8
|
+
from the bowl he dropped the last bean in, until the initial situation appears again.
|
9
|
+
For example with 5 bowls he acts as follows:</p>\r\n\r\n<div align=\"center\"><img
|
10
|
+
src=\"project/images/p_335_mancala.gif\"></div>\r\n\r\n<p>So with 5 bowls it takes
|
11
|
+
Peter 15 moves to return to the initial situation.</p>\r\n\r\n<p>Let <var>M</var>(<var>x</var>)
|
12
|
+
represent the number of moves required to return to the initial situation, starting
|
13
|
+
with <var>x</var> bowls. Thus, <var>M</var>(5) = 15. It can also be verified that
|
14
|
+
<var>M</var>(100) = 10920.</p>\r\n\r\n<p>Find <img style=\"vertical-align:middle\"
|
15
|
+
src=\"project/images/p_335_sum.gif\"><var>M</var>(2<sup><var>k</var></sup>+1). Give
|
16
|
+
your answer modulo 7<sup>9</sup>.</p>\r\n\r\n\r\n"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
:id: 336
|
3
|
+
:name: Maximix Arrangements
|
4
|
+
:url: http://projecteuler.net/problem=336
|
5
|
+
:content: "\r\n<p>A train is used to transport four carriages in the order: ABCD.
|
6
|
+
However, sometimes when the train arrives to collect the carriages they are not
|
7
|
+
in the correct order. <br>\r\nTo rearrange the carriages they are all shunted on
|
8
|
+
to a large rotating turntable. After the carriages are uncoupled at a specific point
|
9
|
+
the train moves off the turntable pulling the carriages still attached with it.
|
10
|
+
The remaining carriages are rotated 180 degrees. All of the carriages are then rejoined
|
11
|
+
and this process is repeated as often as necessary in order to obtain the least
|
12
|
+
number of uses of the turntable.<br>\r\nSome arrangements, such as ADCB, can be
|
13
|
+
solved easily: the carriages are separated between A and D, and after DCB are rotated
|
14
|
+
the correct order has been achieved.</p>\r\n\r\n<p>However, Simple Simon, the train
|
15
|
+
driver, is not known for his efficiency, so he always solves the problem by initially
|
16
|
+
getting carriage A in the correct place, then carriage B, and so on.</p>\r\n\r\n<p>Using
|
17
|
+
four carriages, the worst possible arrangements for Simon, which we shall call <i>maximix
|
18
|
+
arrangements</i>, are DACB and DBAC; each requiring him five rotations (although,
|
19
|
+
using the most efficient approach, they could be solved using just three rotations).
|
20
|
+
The process he uses for DACB is shown below.</p>\r\n\r\n<div align=\"center\"><img
|
21
|
+
src=\"project/images/p_336_maximix.gif\"></div>\r\n\r\n\r\n<p>It can be verified
|
22
|
+
that there are 24 maximix arrangements for six carriages, of which the tenth lexicographic
|
23
|
+
maximix arrangement is DFAECB.</p>\r\n\r\n<p>Find the 2011<sup>th</sup> lexicographic
|
24
|
+
maximix arrangement for eleven carriages.</p>\r\n\r\n"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
:id: 337
|
3
|
+
:name: Totient Stairstep Sequences
|
4
|
+
:url: http://projecteuler.net/problem=337
|
5
|
+
:content: "\r\n<p>Let {a<sub>1</sub>, a<sub>2</sub>,..., a<sub><var>n</var></sub>}
|
6
|
+
be an integer sequence of length <var>n</var> such that:</p>\r\n<ul>\n<li>a<sub>1</sub>
|
7
|
+
= 6</li>\r\n<li>for all 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\"
|
8
|
+
alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>i</var> n : φ(a<sub><var>i</var></sub>)
|
9
|
+
<var>i</var>+1) <var>i</var> <var>i</var>+1 <sup>1</sup>\n</li>\r\n</ul>\n<p>Let
|
10
|
+
S(<var>N</var>) be the number of such sequences with a<sub><var>n</var></sub><img
|
11
|
+
src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>.<br>\r\nFor
|
12
|
+
example, S(10) = 4: {6}, {6, 8}, {6, 8, 9} and {6, 10}.<br>\r\nWe can verify that
|
13
|
+
S(100) = 482073668 and S(10 000) mod 10<sup>8</sup> = 73808307.</p>\r\n\r\n<p>Find
|
14
|
+
S(20 000 000) mod 10<sup>8</sup>.</p>\r\n\r\n<p><sup>1</sup> φ denotes <b>Euler's
|
15
|
+
totient function</b>.</p>\r\n\r\n"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
:id: 338
|
3
|
+
:name: Cutting Rectangular Grid Paper
|
4
|
+
:url: http://projecteuler.net/problem=338
|
5
|
+
:content: "\r\n<p>A rectangular sheet of grid paper with integer dimensions <var>w</var>
|
6
|
+
<img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
7
|
+
style=\"vertical-align:middle;\"><var>h</var> is given. Its grid spacing is 1.<br>\r\nWhen
|
8
|
+
we cut the sheet along the grid lines into two pieces and rearrange those pieces
|
9
|
+
without overlap, we can make new rectangles with different dimensions.</p>\r\n<p>For
|
10
|
+
example, from a sheet with dimensions 9 <img src=\"images/symbol_times.gif\" width=\"9\"
|
11
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 4 , we can
|
12
|
+
make rectangles with dimensions 18 <img src=\"images/symbol_times.gif\" width=\"9\"
|
13
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 2, 12 <img
|
14
|
+
src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
15
|
+
style=\"vertical-align:middle;\"> 3 and 6 <img src=\"images/symbol_times.gif\" width=\"9\"
|
16
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 6 by cutting
|
17
|
+
and rearranging as below:</p>\r\n\r\n<div align=\"center\">\r\n<img src=\"project/images/p_338_gridpaper.gif\"><br>\n</div>\r\n\r\n<p>Similarly,
|
18
|
+
from a sheet with dimensions 9 <img src=\"images/symbol_times.gif\" width=\"9\"
|
19
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 8 , we can
|
20
|
+
make rectangles with dimensions 18 <img src=\"images/symbol_times.gif\" width=\"9\"
|
21
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 4 and 12 <img
|
22
|
+
src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
23
|
+
style=\"vertical-align:middle;\"> 6 .</p>\r\n\r\n<p>For a pair <var>w</var> and
|
24
|
+
<var>h</var>, let F(<var>w</var>,<var>h</var>) be the number of distinct rectangles
|
25
|
+
that can be made from a sheet with dimensions <var>w</var> <img src=\"images/symbol_times.gif\"
|
26
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>h</var>
|
27
|
+
.<br>\r\nFor example, F(2,1) = 0, F(2,2) = 1, F(9,4) = 3 and F(9,8) = 2. <br>\r\nNote
|
28
|
+
that rectangles congruent to the initial one are not counted in F(<var>w</var>,<var>h</var>).<br>\r\nNote
|
29
|
+
also that rectangles with dimensions <var>w</var> <img src=\"images/symbol_times.gif\"
|
30
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>h</var>
|
31
|
+
and dimensions <var>h</var> <img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
|
32
|
+
alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>w</var> are not considered
|
33
|
+
distinct.</p>\r\n\r\n<p>For an integer <var>N</var>, let G(<var>N</var>) be the
|
34
|
+
sum of F(<var>w</var>,<var>h</var>) for all pairs <var>w</var> and <var>h</var>
|
35
|
+
which satisfy 0 <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"<\"
|
36
|
+
border=\"0\" style=\"vertical-align:middle;\"><var>h</var> <img src=\"images/symbol_le.gif\"
|
37
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>w</var>
|
38
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
39
|
+
style=\"vertical-align:middle;\"><var>N</var>.<br>\r\nWe can verify that G(10) =
|
40
|
+
55, G(10<sup>3</sup>) = 971745 and G(10<sup>5</sup>) = 9992617687.</p>\r\n\r\n<p>Find
|
41
|
+
G(10<sup>12</sup>). Give your answer modulo 10<sup>8</sup>.</p>\r\n"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
:id: 339
|
3
|
+
:name: Peredur fab Efrawg
|
4
|
+
:url: http://projecteuler.net/problem=339
|
5
|
+
:content: "\r\n<p>\r\n<i>\"And he came towards a valley, through which ran a river;
|
6
|
+
and the borders of the valley were wooded, and on each side of the river were level
|
7
|
+
meadows. And on one side of the river he saw a flock of white sheep, and on the
|
8
|
+
other a flock of black sheep. And whenever one of the white sheep bleated, one of
|
9
|
+
the black sheep would cross over and become white; and when one of the black sheep
|
10
|
+
bleated, one of the white sheep would cross over and become black.\"</i><br><a href=\"http://en.wikisource.org/wiki/The_Mabinogion/Peredur_the_Son_of_Evrawc\">en.wikisource.org</a>\r\n</p>\r\n<p>\r\n\r\nInitially
|
11
|
+
each flock consists of <var>n</var> sheep. Each sheep (regardless of colour) is
|
12
|
+
equally likely to be the next sheep to bleat. After a sheep has bleated and a sheep
|
13
|
+
from the other flock has crossed over, Peredur may remove a number of white sheep
|
14
|
+
in order to maximize the expected final number of black sheep. Let E(<var>n</var>)
|
15
|
+
be the expected final number of black sheep if Peredur uses an optimal strategy.\r\n</p>\r\n<p>\r\n\r\nYou
|
16
|
+
are given that E(5) = 6.871346 rounded to 6 places behind the decimal point.<br>\r\nFind
|
17
|
+
E(10 000) and give your answer rounded to 6 places behind the decimal point.\r\n</p>\r\n\r\n\r\n"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
:id: 34
|
3
|
+
:name: Digit factorials
|
4
|
+
:url: http://projecteuler.net/problem=34
|
5
|
+
:content: "\r\n\n<p>145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.</p>\n<p>Find
|
6
|
+
the sum of all numbers which are equal to the sum of the factorial of their digits.</p>\n<p
|
7
|
+
class=\"info\">Note: as 1! = 1 and 2! = 2 are not sums they are not included.</p>\n\r\n"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
:id: 340
|
3
|
+
:name: Crazy Function
|
4
|
+
:url: http://projecteuler.net/problem=340
|
5
|
+
:content: "\r\n<p>\r\nFor fixed integers a, b, c, define the <i>crazy function</i>
|
6
|
+
F(<var>n</var>) as follows:<br>\r\nF(<var>n</var>) = <var>n</var> - c for all <var>n</var>
|
7
|
+
<img src=\"images/symbol_gt.gif\" width=\"10\" height=\"10\" alt=\">\" border=\"0\"
|
8
|
+
style=\"vertical-align:middle;\"> b <br>\r\nF(<var>n</var>) = F(a + F(a + F(a +
|
9
|
+
F(a + <var>n</var>)))) for all <var>n</var> <img src=\"images/symbol_le.gif\" width=\"10\"
|
10
|
+
height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"> b.\r\n</p>\r\n<p>\r\nAlso,
|
11
|
+
define S(a, b, c) = <img src=\"project/images/p_340_formula.gif\" style=\"vertical-align:middle;\">.\r\n</p>\r\n<p>\r\nFor
|
12
|
+
example, if a = 50, b = 2000 and c = 40, then F(0) = 3240 and F(2000) = 2040.<br>\r\nAlso,
|
13
|
+
S(50, 2000, 40) = 5204240.\r\n</p>\r\n<p>\r\nFind the last 9 digits of S(21<sup>7</sup>,
|
14
|
+
7<sup>21</sup>, 12<sup>7</sup>).\r\n</p>\r\n\r\n\r\n\r\n\r\n\r\n"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
:id: 341
|
3
|
+
:name: Golomb's self-describing sequence
|
4
|
+
:url: http://projecteuler.net/problem=341
|
5
|
+
:content: "\r\n<p>The <b>Golomb's self-describing sequence</b> {G(<var>n</var>)} is
|
6
|
+
the only nondecreasing sequence of natural numbers such that <var>n</var> appears
|
7
|
+
exactly G(<var>n</var>) times in the sequence. The values of G(<var>n</var>) for
|
8
|
+
the first few <var>n</var> are</p>\r\n\r\n<p></p>\n<div align=\"center\">\r\n<table
|
9
|
+
cellspacing=\"1\" cellpadding=\"5\" border=\"0\" align=\"center\">\n<tr>\n<td align=\"left\"><var>n</var></td>\n<td>1</td>\n<td>2</td>\n<td>3</td>\n<td>4</td>\n<td>5</td>\n<td>6</td>\n<td>7</td>\n<td>8</td>\n<td>9</td>\n<td>10</td>\n<td>11</td>\n<td>12</td>\n<td>13</td>\n<td>14</td>\n<td>15</td>\n<td>…</td>\n</tr>\n<tr>\n<td>G(<var>n</var>)</td>\n<td>1</td>\n<td>2</td>\n<td>2</td>\n<td>3</td>\n<td>3</td>\n<td>4</td>\n<td>4</td>\n<td>4</td>\n<td>5</td>\n<td>5</td>\n<td>5</td>\n<td>6</td>\n<td>6</td>\n<td>6</td>\n<td>6</td>\n<td>…</td>\n</tr>\n</table>\n</div>\r\n\r\n<p>You
|
10
|
+
are given that G(10<sup>3</sup>) = 86, G(10<sup>6</sup>) = 6137.<br>\r\nYou are
|
11
|
+
also given that ΣG(<var>n</var><sup>3</sup>) = 153506976 for 1 <img src=\"images/symbol_le.gif\"
|
12
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>n</var>
|
13
|
+
<img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"<\" border=\"0\"
|
14
|
+
style=\"vertical-align:middle;\"> 10<sup>3</sup>.</p>\r\n\r\n<p>Find ΣG(<var>n</var><sup>3</sup>)
|
15
|
+
for 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
16
|
+
style=\"vertical-align:middle;\"><var>n</var> <img src=\"images/symbol_lt.gif\"
|
17
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\">
|
18
|
+
10<sup>6</sup>.</p>\r\n\r\n\r\n"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
:id: 342
|
3
|
+
:name: The totient of a square is a cube
|
4
|
+
:url: http://projecteuler.net/problem=342
|
5
|
+
:content: "\r\n<p>\r\nConsider the number 50.<br>\r\n50<sup>2</sup> = 2500 = 2<sup>2</sup><img
|
6
|
+
src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
7
|
+
style=\"vertical-align:middle;\"> 5<sup>4</sup>, so φ(2500) = 2 <img src=\"images/symbol_times.gif\"
|
8
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">
|
9
|
+
4 <img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
10
|
+
style=\"vertical-align:middle;\"> 5<sup>3</sup> = 8 <img src=\"images/symbol_times.gif\"
|
11
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">
|
12
|
+
5<sup>3</sup> = 2<sup>3</sup><img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
|
13
|
+
alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"> 5<sup>3</sup>. <sup>1</sup><br>\r\nSo
|
14
|
+
2500 is a square and φ(2500) is a cube.\r\n</p>\r\n<p>\r\nFind the sum of all numbers
|
15
|
+
n, 1 &lt n <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"<\"
|
16
|
+
border=\"0\" style=\"vertical-align:middle;\"> 10<sup>10</sup> such that φ(n<sup>2</sup>)
|
17
|
+
is a cube.\r\n</p>\r\n<p>\r\n<sup>1</sup> φ denotes <b>Euler's totient function</b>.\r\n</p>\r\n\r\n\r\n\r\n"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
:id: 343
|
3
|
+
:name: Fractional Sequences
|
4
|
+
:url: http://projecteuler.net/problem=343
|
5
|
+
:content: "\r\n<p>For any positive integer <var>k</var>, a finite sequence a<sub><var>i</var></sub>
|
6
|
+
of fractions x<sub><var>i</var></sub>/y<sub><var>i</var></sub> is defined by:<br>\r\na<sub>1</sub>
|
7
|
+
= 1/<var>k</var> and<br>\r\na<sub><var>i</var></sub> = (x<sub><var>i</var>-1</sub>+1)/(y<sub><var>i</var>-1</sub>-1)
|
8
|
+
reduced to lowest terms for <var>i</var>>1.<br>\r\nWhen a<sub><var>i</var></sub>
|
9
|
+
reaches some integer <var>n</var>, the sequence stops. (That is, when y<sub><var>i</var></sub>=1.)<br>\r\nDefine
|
10
|
+
f(<var>k</var>) = <var>n</var>. <br>\r\nFor example, for <var>k</var> = 20:\r\n</p>\r\n\r\n<p>\r\n1/20
|
11
|
+
<img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\" border=\"0\"
|
12
|
+
style=\"vertical-align:middle;\"> 2/19 <img src=\"images/symbol_maps.gif\" width=\"15\"
|
13
|
+
height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 3/18 = 1/6
|
14
|
+
<img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\" border=\"0\"
|
15
|
+
style=\"vertical-align:middle;\"> 2/5 <img src=\"images/symbol_maps.gif\" width=\"15\"
|
16
|
+
height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 3/4 <img src=\"images/symbol_maps.gif\"
|
17
|
+
width=\"15\" height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\">
|
18
|
+
4/3 <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\" border=\"0\"
|
19
|
+
style=\"vertical-align:middle;\"> 5/2 <img src=\"images/symbol_maps.gif\" width=\"15\"
|
20
|
+
height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 6/1 = 6\r\n</p>\r\n\r\n<p>\r\nSo
|
21
|
+
f(20) = 6.\r\n</p>\r\n\r\n<p>\r\nAlso f(1) = 1, f(2) = 2, f(3) = 1 and Σf(<var>k</var><sup>3</sup>)
|
22
|
+
= 118937 for 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\"
|
23
|
+
border=\"0\" style=\"vertical-align:middle;\"><var>k</var> <img src=\"images/symbol_le.gif\"
|
24
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\">
|
25
|
+
100.\r\n</p>\r\n\r\n<p>\r\nFind Σf(<var>k</var><sup>3</sup>) for 1 <img src=\"images/symbol_le.gif\"
|
26
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>k</var>
|
27
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
28
|
+
style=\"vertical-align:middle;\"> 2<img src=\"images/symbol_times.gif\" width=\"9\"
|
29
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">10<sup>6</sup>.\r\n</p>\r\n"
|