因为题目给出的n的最大值是100000,即为它的各个位数加起来的和的最大值是1+9+9+9+9+9=46,所以对于任意一个数n,就可以从n-46开始枚举就可以了,检测它是否满足条件。#includeint main(){ long int n,i,s=0,num; scanf("%d",&num.....
分类:
其他好文 时间:
2014-10-25 17:09:31
阅读次数:
158
#includeint main(){ long int n,i,s=0; while(scanf("%d",&n)!=EOF) { int flag=0; for(i=n-46;i<=n;i++) { s=i%10+i/10%10+i/100%10+i/1000%10+i/10000%10...
分类:
其他好文 时间:
2014-10-25 15:40:13
阅读次数:
225
Last non-zero Digit in N!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6276 Accepted Submission(s): 1556
Problem Description...
分类:
其他好文 时间:
2014-10-20 08:44:59
阅读次数:
168
//Given a non-negative number represented as an array of digits, plus one to the number.//The digits are stored such that the most significant digit i...
分类:
其他好文 时间:
2014-10-19 19:47:29
阅读次数:
241
看到网上的一些写法,10进制/12进制/16进制 都写了个子函数,其实统一写个进制求和子函数很简单...
分类:
其他好文 时间:
2014-10-19 17:12:10
阅读次数:
189
Problem:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the ...
分类:
其他好文 时间:
2014-10-18 23:48:28
阅读次数:
156
Problem DescriptionRecently, Mr. Xie learn the concept of happy number. A happy number is a number contain all digit 7 or only 1 digit other than 7. F...
分类:
移动开发 时间:
2014-10-18 11:02:46
阅读次数:
526
题目大意:给定n个数字,求这些数字的全排列中有多少数能被d整除
令f[i][j]为状态为i,余数为j的方案数
枚举最高位转移
小心爆int
#include
#include
#include
#include
using namespace std;
int n,d,ans,f[1<<10][1<<10],digit[1<<10],tens[10],cnt[10],factorial[1...
分类:
其他好文 时间:
2014-10-16 10:38:52
阅读次数:
131
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
class Solution {
pub...
分类:
其他好文 时间:
2014-10-14 16:04:43
阅读次数:
154
题目大意:给定n*n的国际象棋棋盘,在上面放k个国王,要求国王之间互不攻击,求方案数
n
状压DP,将每一行的方案二进制压成一维,令f[i][j][k]为第i行用去j个国王状态为k的方案数,然后状态转移如下:
f[i][j][k]=Σf[i-1][j-digit[k]][l]
其中l&k=0,l>>1&k=0,l
暴力转移即可
记得开long long
#include
#inc...
分类:
其他好文 时间:
2014-10-13 16:30:09
阅读次数:
221