hdu 1333 Smith Numbers】的更多相关文章

刚开始没看清题意,要找的数一定要是素数 ;}…
Description 题目描述 While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University, noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property: The sum of the digits of that nu…
原题直通车: HDU  4722  Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int f[20]; long long work(long long x){ long long ret=0, u=x; int t=0, s=0…
HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的前四位和后四位.  不足8位直接输出. 分析:  前四位有另外一题HDU 1568,用取对的方法来做的.  后四位能够用矩阵高速幂,MOD设成10000即可了. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: http://blog.c…
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10042.html 原创:Smith Numbers - PC110706 作者:MilkCu 题目描述 Smith Numbers   While skimming his phone directory in 1982, mathematician Albert Wilansky noticed that the telepho…
Description While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property: The sum of the digits of that number w…
题意:给定一个N,求一个大于N的最小的Smith Numbers,Smith Numbers是一个合数,且分解质因数之后上质因子每一位上的数字之和 等于 其本身每一位数字之和(别的博客偷的题意) 思路:主要是分治:分解成质因子使用递归即可. #include<cstdio> #include<cmath> // 检测素数 bool is_prime(int n) { ; i*i <= n;++i) ){ ; } ; } //数位 int sumfun(int n) { ; ;…
                               Smith Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14521   Accepted: 4906 Description While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed tha…
定义一种数位simth数,该数的各位之和等于其所有质因子所有位数字之和,现给出n求大于n的最小该种数,n最大不超过8位,那么直接暴力就可以了. /** @Date : 2017-09-08 14:12:08 * @FileName: HDU 1333 素因子 暴力.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ *…
HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2-15 */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define nmax 6000 #define min(a,b) (a<b?a:b…
Poj1142 Smith Numbers Smith Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13854 Accepted: 4716 Description While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed that the telepho…
Smith Numbers Background While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University , noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property: The sum of the digits o…
While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property: The sum of the digits of that number was equal to…
Smith Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14173   Accepted: 4838 Description While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed that the telephone number of his b…
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5)/2)^n)/√5 假设F[n]可以表示成 t * 10^k(t是一个小数),那么对于F[n]取对数log10,答案就为log10 t + K,此时很明显log10 t<1,于是我们去除整数部分,就得到了log10 t 再用pow(10,log10 t)我们就还原回了t.将t×1000就得到了F[n…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 Good Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 422    Accepted Submission(s): 146 Problem Description If we sum up every digit o…
A - Arcane Numbers 1 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4320 Description Vance and Shackler like playing games. One day, they are playing a game called "arcane numbers". Th…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058 解题报告:输入一个n,输出第n个质因子只有2,3,5,7的数. 用了离线打表,因为n最大只有5842. #include<stdio.h> #define INT __int64 INT ans[] = { ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,…
这道题其实也是水题来的,求Fibonacci数的前4位和后4位,在n==40这里分界开.后4位不难求,因为n达到了10^18的规模,所以只能用矩阵快速幂来求了,但在输出后4位的时候一定要注意前导0的处理(我就是在这里wa了一发,也是看了看别人的代码才发现的). 前4位的话稍微有点难处理,我一开始就在想该怎么处理 log10(f(n)) 呢?把f[n]= f[n-1]+f[n-2]? 不行,log对+运算没法展开,我找了好久也没能找到什么能让f[n]展开成相乘或者幂的形式,上网搜了下题解,才发现别…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18238    Accepted Submission(s): 7934 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble numbe…
http://acm.hdu.edu.cn/showproblem.php?pid=4722 [题意]: 找GoodNumbers一个数N,如果它每一个位数字之和可以整除10,那么它就是GoodNumbers,比如451就是一个4+5+1=10,求[A,B]之间这样的数的个数 [题解]: 先写一个暴力代码用来找规律 发现: 0-10    1 0-100  10 0-1000   100 0-990  99 0-992  100 0-997   100 基本规律为 n/10 + (1或0) 加1…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 题目大意:给定一个区间,求区间中有多少个满足每位上的数的和是10的倍数. 解题思路:先打表暴力求出前200项符合条件的个数,然后再找规律. 0~9    0    1个 10~19  9   1个 20~-29  18  1个 0~100         10个 0~200         20个 基本规律:r/10-(l-1)/10;只需要找两端点是否在范围内即可 #include<cstd…
Fibonacci Numbers [题目链接]Fibonacci Numbers [题目类型]矩阵 &题解: 后4位是矩阵快速幂求,前4位是用log加Fibonacci通项公式求,详见上一篇博客 &代码: #include <cstdio> #include <bitset> #include <iostream> #include <set> #include <cmath> #include <cstring>…
http://acm.hdu.edu.cn/showproblem.php?pid=4320 题意: 给出A,B,判断在A进制下的有限小数能否转换成B进制下的有限小数. 思路: 这位博主讲得挺不错的http://blog.csdn.net/dgq8211/article/details/7971960. 我就直接引用了吧... 显然若 n 为整数,一定可以,那么我们下面分析一下 n 含小数的情况. 设 n 的小数部分为 x,且小数部分共 k 位,第 i 位上的数字为 ai. 那么我们可以将 x…
Pseudoprime numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11336   Accepted: 4891 Description Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14584    Accepted Submission(s): 6313 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble numbe…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16742    Accepted Submission(s): 7280 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble numb…
Description If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number.  You are required to count the number of good numbers in the range from A to B, inclusive.   Input The first line has a…
http://acm.hdu.edu.cn/showproblem.php?pid=3117 fib是有一个数学公式的. 这里的是标准的fib公式 那么fib = 1 / sqrt(5) * ((1 + sqrt(5) / 2) ^ n - ((1 - sqrt(5)) / 2)^n) = 1 / sqrt(5) * (A^n - B^n) 那么,求后4位可以直接矩阵快速幂. 不能用上面公式的快速幂取模,因为存在精度误差. 然后求前4位的话,就是一个套路公式了. 在上一篇博客.http://ww…
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<queue> using namespace std; #define ll long long #define maxn 100050 int ok(ll n){ *;i<=n;i++){ ll sum = ,tmp = i; while(tmp){ sum += tmp%; tm…