题目链接:11361 - Investigating Div-Sum Property
白书上的例题,不过没有代码,正好前几天写了一题数位DP的题目,这题也就相对轻松了。
dp[i][x][y]表示加到第i位,数字 % k,数位和 % k的组合情况数,那么现在要添加一个0 - 9的数字上去状态转移为
dp[i + 1][(x * 10 + num) % k][(y + num) % k],计...
                            
                            
                                分类:
其他好文   时间:
2014-05-11 05:23:33   
                                阅读次数:
316
                             
                    
                        
                            
                            
                                Geometric Sum时间限制:1000ms | 
内存限制:65535KB难度:3描述Compute (a + a^2 + … + a^n) mod m.(a+a2+…an)mod输入Three 
integers a,n,m.(1≤a,n,m≤10^18)It ends with EOF.输出T...
                            
                            
                                分类:
其他好文   时间:
2014-05-10 05:01:02   
                                阅读次数:
339
                             
                    
                        
                            
                            
                                聪明的办法是想:求前10位,那只要前8位加起来,进2位就OK。本的办法,就是真的加起来,截前面10位。如我。numList 
= str.split()sum = 0for i in range(0,len(numList)): sum += int(numList[i][0:50]) 
p...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 23:16:32   
                                阅读次数:
350
                             
                    
                        
                            
                            
                                题目链接
迭代加深搜索思想。
枚举答案K,考虑到能否切出K个木头,那么我们当然选最小的K个来切。
1、对于原材料,我们是首选最大的还是最小的?显然,首选大的能够更容易切出,也更容易得到答案。
2、对于目标木头,我们是优先得到最大的还是最小的?显然,由于K个木头我们都要得到,那么当然先把最大的(最难得到的)先得到,这种搜索策略更优。
3、假设总原材料为all,前K个木头总和为sum,那...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 21:07:28   
                                阅读次数:
305
                             
                    
                        
                            
                            
                                是我算法不对,还是笔记本CPU太差?我优化了两次,还是花了三四个小时来得到结果。在输出上加1就是最终结果。The 
sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes 
below two mil...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 16:20:08   
                                阅读次数:
295
                             
                    
                        
                            
                            
                                Path Sum IGiven a binary tree and a sum, 
determine if the tree has a root-to-leaf path such that adding up all the values 
along the path equals the gi...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 13:21:59   
                                阅读次数:
320
                             
                    
                        
                            
                            
                                题目描述N integers are arranged on a circle clockwise. 
Given two integers M and K. For each position, you should take M continuous 
integers on the left an...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 10:30:49   
                                阅读次数:
350
                             
                    
                        
                            
                            
                                Given an array S of n integers, are there 
elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the 
array which gives the sum of ...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 10:27:29   
                                阅读次数:
449
                             
                    
                        
                            
                            
                                1011:#include #include #include #include 
#include using namespace std;const int maxN = 100001;const double eps = 1e-7;int 
n;double m[maxN],sum[maxN];d...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 08:36:06   
                                阅读次数:
303
                             
                    
                        
                            
                            
                                #includeusing namespace std;int main(){ int n = 
0, sum; while (cin>>n) { sum = 0; // 这里要清零 for (int i =0; i <= n; i++) 
{...
                            
                            
                                分类:
其他好文   时间:
2014-05-09 05:38:17   
                                阅读次数:
241