Highly divisible triangular number Problem 12 The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36,…
我的那个暴力求解,太耗时间了. 用了网上产的什么因式分解,质因数之类的.确实快!还是数学基础不行,只能知道大约. The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 2…
title: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of…
最直接的想法就是暴力搞搞,直接枚举,暴力分解因子.再好一点,就打个素数表来分解因子.假设num=p1^a1p2^a2...pn^an,则所有因子个数为(a1+1)(a2+1)...(an+1). 再好一点呢,还是要利用积性函数.假设因子个数函数为f(x),因为num=n(n+1)/2,所以num2=n(n+1),因为n和n+1为相邻的正整数,所以互质,所以f(2num)=f(n)f(n+1), 则f(num)=f(n)f((n+1)/2)(n+1为偶数)或者f(num)=f(n/2)*f(n+1…
Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: Input: "A" Output: 1 Example 2: Input: "AB" Outp…
题目大意 每次询问给出g,l,有\(a*b = g*l = n\),且\(a,b\)均为\(g\)的倍数.求\(a+b\)的最小值和\(a-b\)的最大值. 题解 因为\(a,b\)均为\(g\)的倍数,所以我们另\(a = k_1*g,b = k_2*g\)那么我们有: \(a*b = k_1*k_2*g^2 = g*l\)即\(k_1*k_2 = \frac{l}{g}\) 并且我们有\(a+b = (k_1+k_2)*g\)所以我们发现 \(a+b\)的最小值在\(k_1 = k_2\)时…
本题来自 Project Euler 第12题:https://projecteuler.net/problem=12 # Project Euler: Problem 12: Highly divisible triangular number # The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3…
PE 中文翻译 最喜欢做这种很有意思的数学题了虽然数学很垃圾 但是这个网站的提交方式好鬼畜啊qwq 1.Multiples of 3 and 5 直接枚举 2.Even Fibonacci numbers 直接枚举 3.Largest prime factor $\sqrt(n)$枚举 #include<cstdio> #include<vector> #include<set> #include<algorithm> #define sit #define…
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…
本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter counts If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all th…