You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September,April, June and November.All the rest have thirty-one,Saving February alone,Which has twenty-eight, rain…
import datetime count = 0 for y in range(1901,2001): for m in range(1,13): if datetime.datetime(y,m,1).weekday() == 6: count += 1 print count datetime此功能很好用.省去了计算的麻烦. count = 0 days = 1 year = 365 normal = [31,28,31,30,31,30,31,31,30,31,30,31] leap =…
题意:在二十世纪(1901年1月1日到2000年12月31日)中,有多少个月的1号是星期天? 蔡勒公式:计算 ( year , month , day ) 是星期几 以下图片仅供学习! /************************************************************************* > File Name: euler019.c > Author: WArobot > Blog: http://www.cnblogs.com/WArob…
Problem 19 You are given the following information, but you may prefer to do some research for yourself.以下信息仅供参考(你可能会想自己去百度):1 Jan 1900 was a Monday. 1900年一月一号是星期一Thirty days has September, 九月.四月.六月以及十一月有30天April, June and November.All the rest have…
It is possible to write five as a sum in exactly six different ways: 4 + 1 3 + 2 3 + 1 + 1 2 + 2 + 1 2 + 1 + 1 + 1 1 + 1 + 1 + 1 + 1 How many different ways can one hundred be written as a sum of at least two positive integers? #include <iostream> u…
本题来自 Project Euler 第19题:https://projecteuler.net/problem=19 ''' How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? Answer: 171 ''' from datetime import * firstDay = date(1901,1,1) lastDay = date(…
Problem 28 https://projecteuler.net/problem=28 Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 从1开始,顺时针旋螺转,可得一个5*5的螺旋如下: 21 22 23 24 2520  7  8  9 1019  6  1  2 1118  5  4  3 1217 16 1…
Problem 42 https://projecteuler.net/problem=42 The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... 三角数可由上述公式得出. By converting each letter in a wor…
题目链接:https://projecteuler.net/problem=72 真分数;n/d 当d ≤ 1,000,000时候的真分数有多少个 public class P72{ void run(){ int max_n = 1000000; long[] phi = cal_phi(max_n+1); long sum=0; phi[1] = 0; for(int i =1;i<=max_n;i++) sum+=phi[i]; System.out.println(sum); } //…
题目链接:https://projecteuler.net/problem=73 n/d的真分数 ,当d<=12000时 在 1/3 and 1/2 之间的有多少个 public class P73{ void run(){ FareySequences(); } void FareySequences(){ int limit = 12000; int a = 1; int b = 3; int c = 4000; int d = 11999; int count=0; while(!(c==…
[题目链接:HDOJ-2952] Counting Sheep Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2476    Accepted Submission(s): 1621 Problem Description A while ago I had trouble sleeping. I used to lie awake,…
Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 14   Accepted Submission(s) : 12 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description A while ago I had trou…
算法:深搜 题意:让你判断一共有几个羊圈: 思路:像四个方向搜索: Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the ceiling, for hours and hours. Then one day my grandmother suggested I tried counting sheep after I'd gone to bed. As always…
Description Problem H Counting Rectangles Input: Standard Input Output:Standard Output Time Limit: 3Seconds   Given n points on the XY plane, count how many regular rectanglesare formed. A rectangle is regular if and only if its sides are all paralle…
题目链接 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the ceiling, for hours and hours. Then one day my grandmother suggested I tried counting sheep after I'd gone to bed. As always when my grandmother suggests…
Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 35   Accepted Submission(s) : 24 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description A while ago I had trou…
893E - Counting Arrays 思路:质因子分解. 对于每个质因子,假设它有k个,那么求把它分配到y个数上的方案数. 相当于把k个小球分配到y个盒子里的方案数. 这个问题可以用隔板法(插空法)解决,要把一段分成y段,需要y-1个隔板,那么有y-1+k个位置,选y-1个位置为隔板,剩下的都是小球,那么方案数为C(y-1+k,y-1). 如果全为正数,答案就是所有质因子方案数的积. 但是这道题目可以为负数,那么在这y个数里选偶数个变成负数 答案还要乘以C(y,0)+C(y,2)+C(y…
Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 38   Accepted Submission(s) : 27 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description A while ago I had trou…
版权声明:欢迎关注我的博客.本文为博主[炒饭君]原创文章,未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/25471349 Problem A : Counting Squares pid=1264" rel="nofollow">From:HDU, 1264 Problem Description Your input is a series of rectangles, one per lin…
Counting Sheep Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2060    Accepted Submission(s): 1359 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the c…
Problem 63 https://projecteuler.net/problem=63 Powerful digit counts The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power. 五位数16807同时是7的五次方,同样地,九位数134217728是8的九次方. How many n-digit positiv…
Problem 56 https://projecteuler.net/problem=56 Powerful digit sum A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digi…
Problem 30 https://projecteuler.net/problem=30 Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 很惊奇地,只有三个数字可以写成它们的位数的四次方之和. 1634 = 14 + 64 + 34 + 448208 = 84 + 24 + 04 + 849474 = 94 + 44 + 74 …
Problem 21 https://projecteuler.net/problem=21 Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are c…
Problem 34 https://projecteuler.net/problem=34 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. 145是一个神奇的数字,1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. 找到所有…
Source: PAT A1115 Counting Nodes in a BST (30 分) Description: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than or equal to the no…
Problem 22 Using names.txt (https://projecteuler.net/problem=22)(right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical valu…
Problem 20 问题网址:https://projecteuler.net/problem=20 n! means n × (n − 1) × ... × 3 × 2 × 1阶乘For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digit…
Source: PAT A1004 Counting Leaves (30 分) Description: A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one test case. Each case star…
二,RoundC import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.ArrayList; import java.util.…