码迷,mamicode.com
首页 >  
搜索关键字:nearly prime numbers    ( 9679个结果
hdu 4722 Good Numbers(dp)
题目链接:hdu 4722 Good Numbers 题目大意:给出a,b,问从a到b之间,有多少个好数字,好数字的定义为:每个位的数字相加是10的倍数。 解题思路:dp[i][j]表示第i位,前i-1位的和为j(j可以从200简化成10,以为只需要考虑最后的数是否是10的倍数即可)有多少个数,需要注意的就是恰好为b的情况,所以要有一个跟踪值s。 #include ...
分类:其他好文   时间:2014-05-10 09:46:45    阅读次数:232
LeetCode: Triangle 题解
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:其他好文   时间:2014-05-08 21:08:25    阅读次数:407
shell脚本练习题(更新中...)
练习题(这里贴的是自己写的代码, 网上给的题目代码我会附加在最下面)1.编写shell脚本,计算1-100的和; 1 #!/bin/bash 2 #caculate the sum of numbers from 1 to 100 3 4 sum=0 5 for i in `seq 1 100`;....
分类:其他好文   时间:2014-05-07 19:34:54    阅读次数:305
ProjectEuler_P11
Problem:In the 2020 grid below, four numbers along a diagonal line have been marked in red.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08...
分类:其他好文   时间:2014-05-06 14:35:55    阅读次数:460
Leetcode: Palindrome Numbers
尝试用两头分别比较的方法,结果发现无法解决1000021这种问题 1 public class Solution { 2 public boolean isPalindrome(int x) { 3 if(x= 10) { 6 div *= 10; 7...
分类:其他好文   时间:2014-05-06 10:39:40    阅读次数:241
codechef Permutation Cycles 题解
We consider permutations of the numbers 1,..., N for some N. By permutation we mean a rearrangment of the number 1,...,N. For example 2  4  5  1  7  6  3  8 is a permutation of 1,2,...,8. Of cours...
分类:其他好文   时间:2014-05-04 18:38:14    阅读次数:341
Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm...
分类:其他好文   时间:2014-05-04 10:20:44    阅读次数:240
codechef Prime Palindromes 题解
给定一个数,求一个新数要大于等于这个数,而这个新数既要是palindromes回文又要是prime素数。 题目很简单,有人都使用取巧的方法保存好结果直接查表。 或者暴力法求解。 这里不使用保存表的方法,也不要用暴力法。- 这些方法都不好。 使用的技巧有: 1 而是使用next palindrome的技巧,只需要O(n),n是数位,可以认为是常数了。 2 判断素数的方法,时间效率是O(s...
分类:其他好文   时间:2014-05-04 09:18:17    阅读次数:334
codeforces A. Array题解
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less ...
分类:其他好文   时间:2014-05-03 23:51:19    阅读次数:621
codechef Sums in a Triangle题解
Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear in the second line, three in the third line, etc. Develop a program which will compute the largest ...
分类:其他好文   时间:2014-05-03 17:32:22    阅读次数:284
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!