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,19 @@
|
|
1
|
+
---
|
2
|
+
:id: 403
|
3
|
+
:name: Lattice points enclosed by parabola and line
|
4
|
+
:url: http://projecteuler.net/problem=403
|
5
|
+
:content: "\r\n<p>\r\nFor integers <var>a</var> and <var>b</var>, we define <var>D</var>(<var>a</var>,
|
6
|
+
<var>b</var>) as the domain enclosed by the parabola <var>y</var> = <var>x</var><sup>2</sup>
|
7
|
+
and the line <var>y</var> = <var>a</var>·<var>x</var> + <var>b</var>:<br><var>D</var>(<var>a</var>,
|
8
|
+
<var>b</var>) = { (<var>x</var>, <var>y</var>) | <var>x</var><sup>2</sup><img src=\"images/symbol_le.gif\"
|
9
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>y</var>
|
10
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
11
|
+
style=\"vertical-align:middle;\"><var>a</var>·<var>x</var> + <var>b</var> }.\r\n</p>\r\n<p>\r\nL(<var>a</var>,
|
12
|
+
<var>b</var>) is defined as the number of lattice points contained in <var>D</var>(<var>a</var>,
|
13
|
+
<var>b</var>).<br>\r\nFor example, L(1, 2) = 8 and L(2, -1) = 1.\r\n</p>\r\n<p>\r\nWe
|
14
|
+
also define S(<var>N</var>) as the sum of L(<var>a</var>, <var>b</var>) for all
|
15
|
+
the pairs (<var>a</var>, <var>b</var>) such that the area of <var>D</var>(<var>a</var>,
|
16
|
+
<var>b</var>) is a rational number and |<var>a</var>|,|<var>b</var>| <img src=\"images/symbol_le.gif\"
|
17
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>.<br>\r\nWe
|
18
|
+
can verify that S(5) = 344 and S(100) = 26709528.\r\n</p>\r\n<p>\r\nFind S(10<sup>12</sup>).
|
19
|
+
Give your answer mod 10<sup>8</sup>.\r\n</p>\r\n"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
:id: 404
|
3
|
+
:name: Crisscross Ellipses
|
4
|
+
:url: http://projecteuler.net/problem=404
|
5
|
+
:content: "\r\n<p>\r\nE<sub><var>a</var></sub> is an ellipse with an equation of the
|
6
|
+
form x<sup>2</sup> + 4y<sup>2</sup> = 4<var>a</var><sup>2</sup>.<br>\r\nE<sub><var>a</var></sub>'
|
7
|
+
is the rotated image of E<sub><var>a</var></sub> by θ degrees counterclockwise around
|
8
|
+
the origin O(0, 0) for 0° <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\"
|
9
|
+
alt=\"<\" border=\"0\" style=\"vertical-align:middle;\"> θ <img src=\"images/symbol_lt.gif\"
|
10
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\">
|
11
|
+
90°.\r\n</p>\r\n\r\n<div align=\"center\">\r\n<img src=\"project/images/p_404_c_ellipse.gif\">\n</div>\r\n\r\n<p>\r\n<var>b</var>
|
12
|
+
is the distance to the origin of the two intersection points closest to the origin
|
13
|
+
and <var>c</var> is the distance of the two other intersection points.<br>\r\nWe
|
14
|
+
call an ordered triplet (<var>a</var>, <var>b</var>, <var>c</var>) a <i>canonical
|
15
|
+
ellipsoidal triplet</i> if <var>a</var>, <var>b</var> and <var>c</var> are positive
|
16
|
+
integers.<br>\r\nFor example, (209, 247, 286) is a canonical ellipsoidal triplet.\r\n</p>\r\n\r\n<p>\r\nLet
|
17
|
+
C(<var>N</var>) be the number of distinct canonical ellipsoidal triplets (<var>a</var>,
|
18
|
+
<var>b</var>, <var>c</var>) for <var>a</var> <img src=\"images/symbol_le.gif\" width=\"10\"
|
19
|
+
height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>N</var>.<br>\r\nIt
|
20
|
+
can be verified that C(10<sup>3</sup>) = 7, C(10<sup>4</sup>) = 106 and C(10<sup>6</sup>)
|
21
|
+
= 11845.\r\n</p>\r\n\r\n<p>\r\nFind C(10<sup>17</sup>).\r\n</p>\r\n"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
:id: 405
|
3
|
+
:name: A rectangular tiling
|
4
|
+
:url: http://projecteuler.net/problem=405
|
5
|
+
:content: "\r\n<p>\r\nWe wish to tile a rectangle whose length is twice its width.<br>\r\nLet
|
6
|
+
<var>T</var>(0) be the tiling consisting of a single rectangle.<br>\r\nFor <var>n</var>
|
7
|
+
> 0, let <var>T</var>(<var>n</var>) be obtained from <var>T</var>(<var>n</var>-1)
|
8
|
+
by replacing all tiles in the following manner:\r\n</p>\r\n\r\n<div align=\"center\">\r\n<img
|
9
|
+
src=\"project/images/p_405_tile1.png\">\n</div>\r\n\r\n<p>\r\nThe following animation
|
10
|
+
demonstrates the tilings <var>T</var>(<var>n</var>) for <var>n</var> from 0 to 5:\r\n</p>\r\n\r\n<div
|
11
|
+
align=\"center\">\r\n<img src=\"project/images/p_405_tile2.gif\">\n</div>\r\n\r\n<p>\r\nLet
|
12
|
+
<var>f</var>(<var>n</var>) be the number of points where four tiles meet in <var>T</var>(<var>n</var>).<br>\r\nFor
|
13
|
+
example, <var>f</var>(1) = 0, <var>f</var>(4) = 82 and <var>f</var>(10<sup>9</sup>)
|
14
|
+
mod 17<sup>7</sup> = 126897180.\r\n</p>\r\n\r\n<p>\r\nFind <var>f</var>(10<sup><var>k</var></sup>)
|
15
|
+
for <var>k</var> = 10<sup>18</sup>, give your answer modulo 17<sup>7</sup>.\r\n</p>\r\n"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
:id: 406
|
3
|
+
:name: Guessing Game
|
4
|
+
:url: http://projecteuler.net/problem=406
|
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
|
+
we get one of three possible answers:<br></p>\n<ul>\n<li> \"Your guess is lower
|
8
|
+
than the hidden number\" (and you incur a cost of <var>a</var>), or</li>\r\n<li>
|
9
|
+
\"Your guess is higher than the hidden number\" (and you incur a cost of <var>b</var>),
|
10
|
+
or</li>\r\n<li> \"Yes, that's it!\" (and the game ends).</li>\r\n</ul>\n<p>Given
|
11
|
+
the value of <var>n</var>, <var>a</var>, and <var>b</var>, an <i>optimal strategy</i>
|
12
|
+
minimizes the total cost <u>for the worst possible case</u>.</p>\r\n\r\n<p>For example,
|
13
|
+
if <var>n</var> = 5, <var>a</var> = 2, and <var>b</var> = 3, then we may begin by
|
14
|
+
asking \"<b>2</b>\" as our first question.</p>\r\n\r\n<p>If we are told that 2 is
|
15
|
+
higher than the hidden number (for a cost of <var>b</var>=3), then we are sure that
|
16
|
+
\"<b>1</b>\" is the hidden number (for a total cost of <span style=\"color:blue;\"><b>3</b></span>).<br>\r\nIf
|
17
|
+
we are told that 2 is lower than the hidden number (for a cost of <var>a</var>=2),
|
18
|
+
then our next question will be \"<b>4</b>\".<br>\r\nIf we are told that 4 is higher
|
19
|
+
than the hidden number (for a cost of <var>b</var>=3), then we are sure that \"<b>3</b>\"
|
20
|
+
is the hidden number (for a total cost of 2+3=<span style=\"color:blue;\"><b>5</b></span>).<br>\r\nIf
|
21
|
+
we are told that 4 is lower than the hidden number (for a cost of <var>a</var>=2),
|
22
|
+
then we are sure that \"<b>5</b>\" is the hidden number (for a total cost of 2+2=<span
|
23
|
+
style=\"color:blue;\"><b>4</b></span>).<br>\r\nThus, the worst-case cost achieved
|
24
|
+
by this strategy is <span style=\"color:red;\"><b>5</b></span>. It can also be shown
|
25
|
+
that this is the lowest worst-case cost that can be achieved. \r\nSo, in fact, we
|
26
|
+
have just described an optimal strategy for the given values of <var>n</var>, <var>a</var>,
|
27
|
+
and <var>b</var>.</p>\r\n\r\n<p>Let C(<var>n</var>, <var>a</var>, <var>b</var>)
|
28
|
+
be the worst-case cost achieved by an optimal strategy for the given values of <var>n</var>,
|
29
|
+
<var>a</var>, and <var>b</var>.</p>\r\n\r\n<p>Here are a few examples:<br>\r\nC(5,
|
30
|
+
2, 3) = 5<br>\r\nC(500, <img src=\"images/symbol_radic.gif\" width=\"14\" height=\"16\"
|
31
|
+
alt=\"√\" border=\"0\" style=\"vertical-align:middle;\">2, <img src=\"images/symbol_radic.gif\"
|
32
|
+
width=\"14\" height=\"16\" alt=\"√\" border=\"0\" style=\"vertical-align:middle;\">3)
|
33
|
+
= 13.22073197...<br>\r\nC(20000, 5, 7) = 82<br>\r\nC(2000000, <img src=\"images/symbol_radic.gif\"
|
34
|
+
width=\"14\" height=\"16\" alt=\"√\" border=\"0\" style=\"vertical-align:middle;\">5,
|
35
|
+
<img src=\"images/symbol_radic.gif\" width=\"14\" height=\"16\" alt=\"√\" border=\"0\"
|
36
|
+
style=\"vertical-align:middle;\">7) = 49.63755955...</p>\r\n\r\n<p>Let F<sub><var>k</var></sub>
|
37
|
+
be the Fibonacci numbers: F<sub><var>k</var></sub> = F<sub><var>k</var>-1</sub>
|
38
|
+
+ F<sub><var>k</var>-2</sub> with base cases F<sub>1</sub> = F<sub>2</sub> = 1.<br>Find
|
39
|
+
<img src=\"images/symbol_sum.gif\" width=\"11\" height=\"14\" alt=\"∑\" border=\"0\"
|
40
|
+
style=\"vertical-align:middle;\"><sub>1<img src=\"images/symbol_le.gif\" width=\"10\"
|
41
|
+
height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>k</var><img
|
42
|
+
src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\">30</sub> C(10<sup>12</sup>,
|
43
|
+
<img src=\"images/symbol_radic.gif\" width=\"14\" height=\"16\" alt=\"√\" border=\"0\"
|
44
|
+
style=\"vertical-align:middle;\"><var>k</var>, <img src=\"images/symbol_radic.gif\"
|
45
|
+
width=\"14\" height=\"16\" alt=\"√\" border=\"0\" style=\"vertical-align:middle;\">F<sub><var>k</var></sub>),
|
46
|
+
and give your answer rounded to 8 decimal places behind the decimal point.</p>\r\n"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
:id: 407
|
3
|
+
:name: Idempotents
|
4
|
+
:url: http://projecteuler.net/problem=407
|
5
|
+
:content: "\r\n<p>\r\nIf we calculate <var>a</var><sup>2</sup> mod 6 for 0 <img src=\"images/symbol_le.gif\"
|
6
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>a</var>
|
7
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
8
|
+
style=\"vertical-align:middle;\"> 5 we get: 0,1,4,3,4,1.\r\n</p>\r\n<p>\r\nThe largest
|
9
|
+
value of <var>a</var> such that <var>a</var><sup>2</sup><img src=\"images/symbol_cong.gif\"
|
10
|
+
width=\"9\" height=\"11\" alt=\"≡\" border=\"0\" style=\"vertical-align:middle;\"><var>a</var>
|
11
|
+
mod 6 is 4.<br>\r\nLet's call M(<var>n</var>) the largest value of <var>a</var>
|
12
|
+
<img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"<\" border=\"0\"
|
13
|
+
style=\"vertical-align:middle;\"><var>n</var> such that <var>a</var><sup>2</sup><img
|
14
|
+
src=\"images/symbol_cong.gif\" width=\"9\" height=\"11\" alt=\"≡\" border=\"0\"
|
15
|
+
style=\"vertical-align:middle;\"><var>a</var> (mod <var>n</var>).<br>\r\nSo M(6)
|
16
|
+
= 4.\r\n</p>\r\n<p>\r\nFind <img src=\"images/symbol_sum.gif\" width=\"11\" height=\"14\"
|
17
|
+
alt=\"∑\" border=\"0\" style=\"vertical-align:middle;\">M(<var>n</var>) for 1 <img
|
18
|
+
src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>n</var>
|
19
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
20
|
+
style=\"vertical-align:middle;\"> 10<sup>7</sup>.\r\n</p>\r\n\r\n"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
:id: 408
|
3
|
+
:name: Admissible paths through a grid
|
4
|
+
:url: http://projecteuler.net/problem=408
|
5
|
+
:content: "\r\n<p>Let's call a lattice point (<var>x</var>, <var>y</var>) <i>inadmissible</i>
|
6
|
+
if <var>x</var>, <var>y</var> and <var>x</var> + <var>y</var> are all positive perfect
|
7
|
+
squares.<br>\r\nFor example, (9, 16) is inadmissible, while (0, 4), (3, 1) and (9,
|
8
|
+
4) are not.</p>\r\n\r\n<p>Consider a path from point (<var>x</var><sub>1</sub>,
|
9
|
+
<var>y</var><sub>1</sub>) to point (<var>x</var><sub>2</sub>, <var>y</var><sub>2</sub>)
|
10
|
+
using only unit steps north or east.<br>\r\nLet's call such a path <i>admissible</i>
|
11
|
+
if none of its intermediate points are inadmissible.</p>\r\n\r\n<p>Let P(<var>n</var>)
|
12
|
+
be the number of admissible paths from (0, 0) to (<var>n</var>, <var>n</var>).<br>\r\nIt
|
13
|
+
can be verified that P(5) = 252, P(16) = 596994440 and P(1000) mod 1 000 000 007
|
14
|
+
= 341920854.</p>\r\n\r\n<p>Find P(10 000 000) mod 1 000 000 007.</p>\r\n"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
:id: 409
|
3
|
+
:name: Nim Extreme
|
4
|
+
:url: http://projecteuler.net/problem=409
|
5
|
+
:content: "\r\n<p>Let <var>n</var> be a positive integer. Consider <b>nim</b> positions
|
6
|
+
where:</p>\n<ul>\n<li>There are <var>n</var> non-empty piles.\r\n</li>\n<li>Each
|
7
|
+
pile has size less than 2<sup><var>n</var></sup>.\r\n</li>\n<li>No two piles have
|
8
|
+
the same size.\r\n</li>\n</ul>\n<p>Let W(<var>n</var>) be the number of winning
|
9
|
+
nim positions satisfying the above\r\nconditions (a position is winning if the first
|
10
|
+
player has a winning strategy). For example, W(1) = 1, W(2) = 6, W(3) = 168, W(5)
|
11
|
+
= 19764360 and W(100) mod 1 000 000 007 = 384777056.\r\n</p>\r\n<p>Find W(10 000 000)
|
12
|
+
mod 1 000 000 007.\r\n</p>\r\n\r\n"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
---
|
2
|
+
:id: 41
|
3
|
+
:name: Pandigital prime
|
4
|
+
:url: http://projecteuler.net/problem=41
|
5
|
+
:content: "\r\n\n<p>We shall say that an <i>n</i>-digit number is pandigital if it
|
6
|
+
makes use of all the digits 1 to <i>n</i> exactly once. For example, 2143 is a 4-digit
|
7
|
+
pandigital and is also prime.</p>\n<p>What is the largest <i>n</i>-digit pandigital
|
8
|
+
prime that exists?</p>\n\r\n"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
:id: 410
|
3
|
+
:name: Circle and tangent line
|
4
|
+
:url: http://projecteuler.net/problem=410
|
5
|
+
:content: "\r\n<p>Let C be the circle with radius <var>r</var>, <var>x</var><sup>2</sup>
|
6
|
+
+ <var>y</var><sup>2</sup> = <var>r</var><sup>2</sup>. We choose two points P(<var>a</var>,
|
7
|
+
<var>b</var>) and Q(-<var>a</var>, <var>c</var>) so that the line passing through
|
8
|
+
P and Q is tangent to C.</p>\r\n\r\n<p>For example, the quadruplet (<var>r</var>,
|
9
|
+
<var>a</var>, <var>b</var>, <var>c</var>) = (2, 6, 2, -7) satisfies this property.</p>\r\n\r\n<p>Let
|
10
|
+
F(<var>R</var>, <var>X</var>) be the number of the integer quadruplets (<var>r</var>,
|
11
|
+
<var>a</var>, <var>b</var>, <var>c</var>) with this property, and with 0 <img src=\"images/symbol_lt.gif\"
|
12
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\"><var>r</var>
|
13
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
14
|
+
style=\"vertical-align:middle;\"><var>R</var> and 0 <img src=\"images/symbol_lt.gif\"
|
15
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\"><var>a</var>
|
16
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
17
|
+
style=\"vertical-align:middle;\"><var>X</var>.</p>\r\n\r\n<p>We can verify that
|
18
|
+
F(1, 5) = 10, F(2, 10) = 52 and F(10, 100) = 3384.<br>\r\nFind F(10<sup>8</sup>,
|
19
|
+
10<sup>9</sup>) + F(10<sup>9</sup>, 10<sup>8</sup>).</p>\r\n"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
:id: 411
|
3
|
+
:name: Uphill paths
|
4
|
+
:url: http://projecteuler.net/problem=411
|
5
|
+
:content: "\r\n<p>\r\nLet <var>n</var> be a positive integer. Suppose there are stations
|
6
|
+
at the coordinates (<var>x</var>, <var>y</var>) = (2<sup><var>i</var></sup> mod
|
7
|
+
<var>n</var>, 3<sup><var>i</var></sup> mod <var>n</var>) for 0 <img src=\"images/symbol_le.gif\"
|
8
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>i</var>
|
9
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
10
|
+
style=\"vertical-align:middle;\"> 2<var>n</var>. We will consider stations with
|
11
|
+
the same coordinates as the same station.\r\n</p>\n<p>\r\nWe wish to form a path
|
12
|
+
from (0, 0) to (<var>n</var>, <var>n</var>) such that the x and y coordinates never
|
13
|
+
decrease.<br>\r\nLet S(<var>n</var>) be the maximum number of stations such a path
|
14
|
+
can pass through.\r\n</p>\n<p>\r\nFor example, if <var>n</var> = 22, there are 11
|
15
|
+
distinct stations, and a valid path can pass through at most 5 stations. Therefore,
|
16
|
+
S(22) = 5.\r\nThe case is illustrated below, with an example of an optimal path:\r\n</p>\r\n<p
|
17
|
+
align=\"center\"><img src=\"project/images/p411_longpath.png\"></p>\r\n<p>\r\nIt
|
18
|
+
can also be verified that S(123) = 14 and S(10000) = 48.\r\n</p>\n<p>\r\nFind <img
|
19
|
+
src=\"images/symbol_sum.gif\" width=\"11\" height=\"14\" alt=\"∑\" border=\"0\"
|
20
|
+
style=\"vertical-align:middle;\"> S(<var>k</var><sup>5</sup>) for 1 <img src=\"images/symbol_le.gif\"
|
21
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>k</var>
|
22
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
23
|
+
style=\"vertical-align:middle;\"> 30.\r\n</p>\r\n"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
:id: 412
|
3
|
+
:name: Gnomon numbering
|
4
|
+
:url: http://projecteuler.net/problem=412
|
5
|
+
:content: "\r\n<p>For integers <var>m</var>, <var>n</var> (0 <img src=\"images/symbol_le.gif\"
|
6
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"> <var>n</var> m),
|
7
|
+
let L(<var>m</var>, <var>n</var>) be an <var>m</var><img src=\"images/symbol_times.gif\"
|
8
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>m</var>
|
9
|
+
grid with the top-right <var>n</var><img src=\"images/symbol_times.gif\" width=\"9\"
|
10
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\"><var>n</var>
|
11
|
+
grid removed.</p>\r\n\r\n<p>For example, L(5, 3) looks like this:</p>\r\n\r\n<p><img
|
12
|
+
src=\"project/images/p412_table53.png\"></p>\r\n\r\n<p>We want to number each cell
|
13
|
+
of L(<var>m</var>, <var>n</var>) with consecutive integers 1, 2, 3, ... such that
|
14
|
+
the number in every cell is smaller than the number below it and to the left of
|
15
|
+
it.</p>\r\n\r\n<p>For example, here are two valid numberings of L(5, 3):</p>\r\n<p><img
|
16
|
+
src=\"project/images/p412_tablenums.png\"></p>\r\n\r\n<p>Let LC(<var>m</var>, <var>n</var>)
|
17
|
+
be the number of valid numberings of L(<var>m</var>, <var>n</var>).<br>\r\nIt can
|
18
|
+
be verified that LC(3, 0) = 42, LC(5, 3) = 250250, LC(6, 3) = 406029023400 and LC(10, 5)
|
19
|
+
mod 76543217 = 61251715.</p>\r\n\r\n<p>Find LC(10000, 5000) mod 76543217.</p>\r\n"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
:id: 413
|
3
|
+
:name: One-child Numbers
|
4
|
+
:url: http://projecteuler.net/problem=413
|
5
|
+
:content: "\r\n<p>We say that a <var>d</var>-digit positive number (no leading zeros)
|
6
|
+
is a one-child number if exactly one of its sub-strings is divisible by <var>d</var>.</p>\r\n\r\n<p>For
|
7
|
+
example, 5671 is a 4-digit one-child number. Among all its sub-strings 5, 6, 7,
|
8
|
+
1, 56, 67, 71, 567, 671 and 5671, only 56 is divisible by 4.<br>\r\nSimilarly, 104
|
9
|
+
is a 3-digit one-child number because only 0 is divisible by 3.<br>\r\n1132451 is
|
10
|
+
a 7-digit one-child number because only 245 is divisible by 7.</p>\r\n\r\n<p>Let
|
11
|
+
F(<var>N</var>) be the number of the one-child numbers less than <var>N</var>.<br>\r\nWe
|
12
|
+
can verify that F(10) = 9, F(10<sup>3</sup>) = 389 and F(10<sup>7</sup>) = 277674.</p>\r\n\r\n<p>Find
|
13
|
+
F(10<sup>19</sup>).</p>\r\n"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
:id: 414
|
3
|
+
:name: Kaprekar constant
|
4
|
+
:url: http://projecteuler.net/problem=414
|
5
|
+
:content: "\r\n<p>\r\n6174 is a remarkable number; if we sort its digits in increasing
|
6
|
+
order and subtract that number from the number you get when you sort the digits
|
7
|
+
in decreasing order, we get 7641-1467=6174.<br>\r\nEven more remarkable is that
|
8
|
+
if we start from any 4 digit number and repeat this process of sorting and subtracting,
|
9
|
+
we'll eventually end up with 6174 or immediately with 0 if all digits are equal.<br>
|
10
|
+
\r\nThis also works with numbers that have less than 4 digits if we pad the number
|
11
|
+
with leading zeroes until we have 4 digits.<br>\r\nE.g. let's start with the number
|
12
|
+
0837:<br>\r\n8730-0378=8352<br>\r\n8532-2358=6174\r\n</p>\r\n<p>\r\n6174 is called
|
13
|
+
the <b>Kaprekar constant</b>. The process of sorting and subtracting and repeating
|
14
|
+
this until either 0 or the Kaprekar constant is reached is called the <b>Kaprekar
|
15
|
+
routine</b>.\r\n</p>\r\n<p>\r\nWe can consider the Kaprekar routine for other bases
|
16
|
+
and number of digits.<br> \r\nUnfortunately, it is not guaranteed a Kaprekar constant
|
17
|
+
exists in all cases; either the routine can end up in a cycle for some input numbers
|
18
|
+
or the constant the routine arrives at can be different for different input numbers.<br>\r\nHowever,
|
19
|
+
it can be shown that for 5 digits and a base b = 6t+3<img src=\"images/symbol_ne.gif\"
|
20
|
+
width=\"11\" height=\"10\" alt=\"≠\" border=\"0\" style=\"vertical-align:middle;\">9,
|
21
|
+
a Kaprekar constant exists.<br>\r\nE.g. base 15: (10,4,14,9,5)<sub>15</sub><br>\r\nbase
|
22
|
+
21: (14,6,20,13,7)<sub>21</sub></p>\r\n<p>\r\nDefine <var>C<sub>b</sub></var> to
|
23
|
+
be the Kaprekar constant in base <var>b</var> for 5 digits.\r\nDefine the function
|
24
|
+
<var>sb(i)</var> to be\r\n</p>\n<ul>\n<li> 0 if i = <var>C<sub>b</sub></var> or
|
25
|
+
if <var>i</var> written in base <var>b</var> consists of 5 identical digits\r\n</li>\n<li>
|
26
|
+
the number of iterations it takes the Kaprekar routine in base <var>b</var> to arrive
|
27
|
+
at <var>C<sub>b</sub></var>, otherwise\r\n</li>\n</ul>\r\nNote that we can define
|
28
|
+
<var>sb(i)</var> for all integers <var>i</var> <img src=\"images/symbol_lt.gif\"
|
29
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\"><var>b</var><sup>5</sup>.
|
30
|
+
If <var>i</var> written in base <var>b</var> takes less than 5 digits, the number
|
31
|
+
is padded with leading zero digits until we have 5 digits before applying the Kaprekar
|
32
|
+
routine.\r\n\r\n<p>\r\nDefine <var>S(b)</var> as the sum of <var>sb(i)</var> for
|
33
|
+
0 <img src=\"images/symbol_lt.gif\" width=\"10\" height=\"10\" alt=\"<\" border=\"0\"
|
34
|
+
style=\"vertical-align:middle;\"><var>i</var> <img src=\"images/symbol_lt.gif\"
|
35
|
+
width=\"10\" height=\"10\" alt=\"<\" border=\"0\" style=\"vertical-align:middle;\"><var>b</var><sup>5</sup>.<br>\r\nE.g.
|
36
|
+
S(15) = 5274369<br> \r\nS(111) = 400668930299\r\n</p>\r\n<p>\r\nFind the sum of
|
37
|
+
S(6k+3) for 2 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\"
|
38
|
+
border=\"0\" style=\"vertical-align:middle;\"> k <img src=\"images/symbol_le.gif\"
|
39
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\">
|
40
|
+
300.<br>\r\nGive the last 18 digits as your answer.\r\n</p>\r\n\r\n"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
:id: 415
|
3
|
+
:name: Titanic sets
|
4
|
+
:url: http://projecteuler.net/problem=415
|
5
|
+
:content: "\r\n<p>A set of lattice points S is called a <i>titanic set</i> if there
|
6
|
+
exists a line passing through exactly two points in S.</p>\r\n\r\n<p>An example
|
7
|
+
of a titanic set is S = {(0, 0), (0, 1), (0, 2), (1, 1), (2, 0), (1, 0)}, where
|
8
|
+
the line passing through (0, 1) and (2, 0) does not pass through any other point
|
9
|
+
in S.</p>\r\n\r\n<p>On the other hand, the set {(0, 0), (1, 1), (2, 2), (4, 4)}
|
10
|
+
is not a titanic set since the line passing through any two points in the set also
|
11
|
+
passes through the other two.</p>\r\n\r\n<p>For any positive integer <var>N</var>,
|
12
|
+
let <var>T</var>(<var>N</var>) be the number of titanic sets S whose every point
|
13
|
+
(<var>x</var>, <var>y</var>) satisfies 0 <img src=\"images/symbol_le.gif\" width=\"10\"
|
14
|
+
height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>x</var>,
|
15
|
+
<var>y</var> <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\"
|
16
|
+
border=\"0\" style=\"vertical-align:middle;\"><var>N</var>.\r\nIt can be verified
|
17
|
+
that <var>T</var>(1) = 11, <var>T</var>(2) = 494, <var>T</var>(4) = 33554178, <var>T</var>(111)
|
18
|
+
mod 10<sup>8</sup> = 13500401 and <var>T</var>(10<sup>5</sup>) mod 10<sup>8</sup>
|
19
|
+
= 63259062.</p>\r\n\r\n<p>Find <var>T</var>(10<sup>11</sup>) mod 10<sup>8</sup>.</p>\r\n\r\n"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
:id: 416
|
3
|
+
:name: A frog's trip
|
4
|
+
:url: http://projecteuler.net/problem=416
|
5
|
+
:content: "\r\n<p>A row of <var>n</var> squares contains a frog in the leftmost square.
|
6
|
+
By successive jumps the frog goes to the rightmost square and then back to the leftmost
|
7
|
+
square. On the outward trip he jumps one, two or three squares to the right, and
|
8
|
+
on the homeward trip he jumps to the left in a similar manner. He cannot jump outside
|
9
|
+
the squares. He repeats the round-trip travel <var>m</var> times.</p>\r\n\r\n<p>Let
|
10
|
+
F(<var>m</var>, <var>n</var>) be the number of the ways the frog can travel so that
|
11
|
+
at most one square remains unvisited.<br>\r\nFor example, F(1, 3) = 4, F(1, 4) =
|
12
|
+
15, F(1, 5) = 46, F(2, 3) = 16 and F(2, 100) mod 10<sup>9</sup> = 429619151.</p>\r\n\r\n<p>Find
|
13
|
+
the last 9 digits of F(10, 10<sup>12</sup>).</p>\r\n"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
:id: 417
|
3
|
+
:name: Reciprocal cycles II
|
4
|
+
:url: http://projecteuler.net/problem=417
|
5
|
+
:content: "\r\n<p>A unit fraction contains 1 in the numerator. The decimal representation
|
6
|
+
of the unit fractions with denominators 2 to 10 are given:</p>\r\n<blockquote>\r\n<table>\n<tr>\n<td>\n<sup>1</sup>/<sub>2</sub>\n</td>\n<td>= </td>\n<td>0.5</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>3</sub>\n</td>\n<td>= </td>\n<td>0.(3)</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>4</sub>\n</td>\n<td>= </td>\n<td>0.25</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>5</sub>\n</td>\n<td>= </td>\n<td>0.2</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>6</sub>\n</td>\n<td>= </td>\n<td>0.1(6)</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>7</sub>\n</td>\n<td>= </td>\n<td>0.(142857)</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>8</sub>\n</td>\n<td>= </td>\n<td>0.125</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>9</sub>\n</td>\n<td>= </td>\n<td>0.(1)</td>\r\n</tr>\n<tr>\n<td>\n<sup>1</sup>/<sub>10</sub>\n</td>\n<td>= </td>\n<td>0.1</td>\r\n</tr>\n</table>\n</blockquote>\r\n<p>Where
|
7
|
+
0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that
|
8
|
+
<sup>1</sup>/<sub>7</sub> has a 6-digit recurring cycle.</p>\r\n<p>\r\nUnit fractions
|
9
|
+
whose denominator has no other prime factors than 2 and/or 5 are not considered
|
10
|
+
to have a recurring cycle.<br>\r\nWe define the length of the recurring cycle of
|
11
|
+
those unit fractions as 0. \r\n</p>\r\n<p>\r\nLet L(n) denote the length of the
|
12
|
+
recurring cycle of 1/n.\r\nYou are given that <img src=\"images/symbol_sum.gif\"
|
13
|
+
width=\"11\" height=\"14\" alt=\"∑\" border=\"0\" style=\"vertical-align:middle;\">L(n)
|
14
|
+
for 3 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
15
|
+
style=\"vertical-align:middle;\"> n <img src=\"images/symbol_le.gif\" width=\"10\"
|
16
|
+
height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"> 1 000 000
|
17
|
+
equals 55535191115.\r\n</p>\r\n<p>\r\nFind <img src=\"images/symbol_sum.gif\" width=\"11\"
|
18
|
+
height=\"14\" alt=\"∑\" border=\"0\" style=\"vertical-align:middle;\">L(n) for 3
|
19
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
20
|
+
style=\"vertical-align:middle;\"> n <img src=\"images/symbol_le.gif\" width=\"10\"
|
21
|
+
height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"> 100 000 000\r\n</p>"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
:id: 418
|
3
|
+
:name: Factorisation triples
|
4
|
+
:url: http://projecteuler.net/problem=418
|
5
|
+
:content: "\r\n<p>\r\nLet <var>n</var> be a positive integer. An integer triple (<var>a</var>,
|
6
|
+
<var>b</var>, <var>c</var>) is called a <i>factorisation triple</i> of <var>n</var>
|
7
|
+
if:</p>\n<ul>\n<li> 1 <img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\"
|
8
|
+
alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>a</var> <img src=\"images/symbol_le.gif\"
|
9
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\"><var>b</var>
|
10
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
11
|
+
style=\"vertical-align:middle;\"><var>c</var>\r\n</li>\n<li> <var>a</var>·<var>b</var>·<var>c</var>
|
12
|
+
= <var>n</var>.\r\n</li>\n</ul>\n<p>\r\nDefine <var>f</var>(<var>n</var>) to be
|
13
|
+
<var>a</var> + <var>b</var> + <var>c</var> for the factorisation triple (<var>a</var>,
|
14
|
+
<var>b</var>, <var>c</var>) of <var>n</var> which minimises <var>c</var> / <var>a</var>.
|
15
|
+
One can show that this triple is unique.\r\n</p>\r\n<p>\r\nFor example, <var>f</var>(165)
|
16
|
+
= 19, <var>f</var>(100100) = 142 and <var>f</var>(20!) = 4034872.\r\n</p>\r\n<p>\r\nFind
|
17
|
+
<var>f</var>(43!).\r\n</p>\r\n"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
:id: 419
|
3
|
+
:name: Look and say sequence
|
4
|
+
:url: http://projecteuler.net/problem=419
|
5
|
+
:content: "\r\n<p>\r\nThe <b>look and say</b> sequence goes 1, 11, 21, 1211, 111221,
|
6
|
+
312211, 13112221, 1113213211, ...<br>\r\nThe sequence starts with 1 and all other
|
7
|
+
members are obtained by describing the previous member in terms of consecutive digits.<br>\r\nIt
|
8
|
+
helps to do this out loud:<br>\r\n1 is 'one one' <img src=\"images/symbol_maps.gif\"
|
9
|
+
width=\"15\" height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\">
|
10
|
+
11<br>\r\n11 is 'two ones' <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\"
|
11
|
+
alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 21<br>\r\n21 is 'one two
|
12
|
+
and one one' <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\" alt=\"→\"
|
13
|
+
border=\"0\" style=\"vertical-align:middle;\"> 1211 <br>\r\n1211 is 'one one, one
|
14
|
+
two and two ones' <img src=\"images/symbol_maps.gif\" width=\"15\" height=\"7\"
|
15
|
+
alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 111221<br>\r\n111221 is
|
16
|
+
'three ones, two twos and one one' <img src=\"images/symbol_maps.gif\" width=\"15\"
|
17
|
+
height=\"7\" alt=\"→\" border=\"0\" style=\"vertical-align:middle;\"> 312211<br>\r\n...\r\n</p>\r\n<p>\r\nDefine
|
18
|
+
A(n), B(n) and C(n) as the number of ones, twos and threes in the n'th element of
|
19
|
+
the sequence respectively.<br>\r\nOne can verify that A(40) = 31254, B(40) = 20259
|
20
|
+
and C(40) = 11625.\r\n</p>\r\n<p>\r\nFind A(n), B(n) and C(n) for n = 10<sup>12</sup>.<br>
|
21
|
+
\r\nGive your answer modulo 2<sup>30</sup> and separate your values for A, B and
|
22
|
+
C by a comma.<br> \r\nE.g. for n = 40 the answer would be 31254,20259,11625\r\n</p>\r\n\r\n\r\n"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
:id: 42
|
3
|
+
:name: Coded triangle numbers
|
4
|
+
:url: http://projecteuler.net/problem=42
|
5
|
+
:content: "\r\n<p>The <i>n</i><sup>th</sup> term of the sequence of triangle numbers
|
6
|
+
is given by, <i>t<sub>n</sub></i> = ½<i>n</i>(<i>n</i>+1); so the first ten triangle
|
7
|
+
numbers are:</p>\r\n<p style=\"text-align:center;\">1, 3, 6, 10, 15, 21, 28, 36,
|
8
|
+
45, 55, ...</p>\r\n<p>By converting each letter in a word to a number corresponding
|
9
|
+
to its alphabetical position and adding these values we form a word value. For example,
|
10
|
+
the word value for SKY is 19 + 11 + 25 = 55 = <i>t</i><sub>10</sub>. If the word
|
11
|
+
value is a triangle number then we shall call the word a triangle word.</p>\r\n<p>Using
|
12
|
+
<a href=\"project/words.txt\">words.txt</a> (right click and 'Save Link/Target As...'),
|
13
|
+
a 16K text file containing nearly two-thousand common English words, how many are
|
14
|
+
triangle words?</p>\r\n"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
:id: 420
|
3
|
+
:name: 2x2 positive integer matrix
|
4
|
+
:url: http://projecteuler.net/problem=420
|
5
|
+
:content: "\r\n<p>A <i>positive integer matrix</i> is a matrix whose elements are
|
6
|
+
all positive integers.<br>\r\nSome positive integer matrices can be expressed as
|
7
|
+
a square of a positive integer matrix in two different ways. Here is an example:</p>\r\n\r\n<div
|
8
|
+
align=\"center\">\r\n<img src=\"project/images/p_420_matrix.gif\">\n</div>\r\n\r\n<p>\r\nWe
|
9
|
+
define F(<var>N</var>) as the number of the 2x2 positive integer matrices which
|
10
|
+
have a <dfn title=\"the sum of the elements on the main diagonal\">trace</dfn> less
|
11
|
+
than <var>N</var> and which can be expressed as a square of a positive integer matrix
|
12
|
+
in two different ways.<br>\r\nWe can verify that F(50) = 7 and F(1000) = 1019.\r\n</p>\r\n\r\n<p>\r\nFind
|
13
|
+
F(10<sup>7</sup>).\r\n</p>\r\n"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
:id: 421
|
3
|
+
:name: Prime factors of <var>n</var><sup>15</sup>+1
|
4
|
+
:url: http://projecteuler.net/problem=421
|
5
|
+
:content: "\r\n<p>\r\nNumbers of the form <var>n</var><sup>15</sup>+1 are composite
|
6
|
+
for every integer <var>n</var> <img src=\"images/symbol_gt.gif\" width=\"10\" height=\"10\"
|
7
|
+
alt=\">\" border=\"0\" style=\"vertical-align:middle;\"> 1.<br>\r\nFor positive
|
8
|
+
integers <var>n</var> and <var>m</var> let <var>s</var>(<var>n,m</var>) be defined
|
9
|
+
as the sum of the <i>distinct</i> prime factors of <var>n</var><sup>15</sup>+1 not
|
10
|
+
exceeding <var>m</var>.\r\n</p>\r\nE.g. 2<sup>15</sup>+1 = 3<img src=\"images/symbol_times.gif\"
|
11
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">3<img
|
12
|
+
src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
13
|
+
style=\"vertical-align:middle;\">11<img src=\"images/symbol_times.gif\" width=\"9\"
|
14
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">331.<br>\r\nSo
|
15
|
+
<var>s</var>(2,10) = 3 and <var>s</var>(2,1000) = 3+11+331 = 345.<br><br>\r\n\r\nAlso
|
16
|
+
10<sup>15</sup>+1 = 7<img src=\"images/symbol_times.gif\" width=\"9\" height=\"9\"
|
17
|
+
alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">11<img src=\"images/symbol_times.gif\"
|
18
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">13<img
|
19
|
+
src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
20
|
+
style=\"vertical-align:middle;\">211<img src=\"images/symbol_times.gif\" width=\"9\"
|
21
|
+
height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">241<img src=\"images/symbol_times.gif\"
|
22
|
+
width=\"9\" height=\"9\" alt=\"×\" border=\"0\" style=\"vertical-align:middle;\">2161<img
|
23
|
+
src=\"images/symbol_times.gif\" width=\"9\" height=\"9\" alt=\"×\" border=\"0\"
|
24
|
+
style=\"vertical-align:middle;\">9091.<br>\r\nSo <var>s</var>(10,100) = 31 and <var>s</var>(10,1000)
|
25
|
+
= 483.<br><p>\r\nFind &Sum; <var>s</var>(<var>n</var>,10<sup>8</sup>) for 1
|
26
|
+
<img src=\"images/symbol_le.gif\" width=\"10\" height=\"12\" alt=\"≤\" border=\"0\"
|
27
|
+
style=\"vertical-align:middle;\"><var>n</var> <img src=\"images/symbol_le.gif\"
|
28
|
+
width=\"10\" height=\"12\" alt=\"≤\" border=\"0\" style=\"vertical-align:middle;\">
|
29
|
+
10<sup>11</sup>.\r\n</p>\r\n\r\n"
|