The 70th problem,UVa10396 Vampire Numbers】的更多相关文章

今天看Thinking in Java看到一个吸血鬼数的问题,于是查找UVa里也有类似的问题就动手写了先是用Java写的,不过WA了两次,然后没有发现错误,又用c++写的还是不行.最后发现要排序去重.然后改用Java的SortedSet解决了这个问题,主要就是暴力枚举求解.但是同样的算法Java用了将近5秒.c++只用了1秒.差距啊.还有避免不必要的重复的循环不能为00,还有不能为奇数.尽量提高程序的效率. 题目描述: Problem D Vampire Numbers Input: stand…
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper d…
1565: Vampire Numbers 时间限制: 3 Sec  内存限制: 128 MB提交: 20  解决: 9[提交][状态][讨论版] 题目描述 The number 1827 is an interesting number, because 1827=21*87, and all of the same digits appear on both sides of the `='. The number136948 has the same property: 136948=14…
集覆盖问题研究满足覆盖所有需求点顾客的前提下,服务站总的建站个数或建 设费用最小的问题.集覆盖问题最早是由 Roth和 Toregas等提出的,用于解决消防中心和救护车等的应急服务设施的选址问题,他们分别建立了服务站建站成本不同和相同情况下集覆盖问题的整数规划模 型.   中文名 覆盖问题 外文名 Maximum Covering Location Problem,MCLP 分    类 问题 作    用 覆盖 目录 1 简介分类 2 覆盖问题 ▪ 集覆盖问题 ▪ 最大覆盖问题 简介分类 编辑…
拜占庭将军问题(Byzantine Generals Problem),一个关于分布式系统容错问题故事 背景:拜占庭帝国派出10支军队,去包围进攻一个强大的敌人,至少6支军队同时进攻才能攻下敌国. 难题:一些将军可能是叛徒,会发布假的(相反的)进攻意向. 目的:将军们需要找到一种共识机制,可以远程协商,赢取战斗. 解决方案:每个节点给所有的其它节点发送消息,每个节点根据接收到的所有消息来决定最终的策略. 缺点:每个节点向全网节点发送大量的消息. 节点数多的时候就会导致通信堵塞,所以比特币没有采用…
不定长数组:vector vector就是一个不定长数组.不仅如此,它把一些常用操作“封装”在了vector类型内部. 例如,若a是一个vector,可以用a.size( )读取它的大小,a.resize( )改变大小,a.push_back( )向 尾部添加元素,a.pop_back( )删除最后一个元素. vector是一个模板类,所以需要用vectora或者vectorb这样的方式来声明一 个vector.Vector是一个类似于inta[]的整数数组,而vector就是一个类似于 str…
Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. For example, if n is 10, the output should be “2, 3, 5, 7″. If n is 20, the output should be “2, 3, 5, 7, 11, 13,…
题目原文: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6…
Problem Description   Coco has a tree, whose vertices are conveniently labeled by 1,2,…,n.There are m chain on the tree, Each chain has a certain weight. Coco would like to pick out some chains any two of which do not share common vertices.Find out t…
题目描述: A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number of first circle should always be 1. 输入: n (1 < n…
A Simple Math Problem 一个矩阵快速幂水题,关键在于如何构造矩阵.做过一些很裸的矩阵快速幂,比如斐波那契的变形,这个题就类似那种构造.比赛的时候手残把矩阵相乘的一个j写成了i,调试了好久才发现.改过来1A. 贴个AC的代码: const int N=1e5+10; ll k,m,s[10]; struct mat { ll a[10][10]; }; mat mat_mul(mat A,mat B) { mat res; memset(res.a,0,sizeof(res.a…
Root of the Problem Time Limit: 1000MS   Memory Limit: 65536K               http://poj.org/problem?id=3100    已AK; Description Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approxima…
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae: Triangle   P3,n=n(n+1)/2   1, 3, 6, 10, 15, ... Square   P4,n=n2   1, 4, 9, 16, 25, ... Penta…
Prime Ring Problem                                                                                                                Time Limit: 4000/2000 MS (Java/Others)                                                                                  …
本文转载自:http://blog.csdn.net/a567890k/article/details/52956798 最近编译Android6.0时经常出现以下错误 临时解决方法: Building with Jack: out/target/common/obj/APPS/Launcher3_intermediates/with-local/classes.dexERROR: Security problem, see Jack server log (/tmp/jack-weilan/j…
水题,输出的时候注意下 #include <stdio.h> #include <math.h> int main() { int d; scanf("%d",&d); while(d--) { ]; ; scanf("%d",&n); ) { binary[i++]=n%; n/=; } ; ;j<i;j++) { if(binary[j]) { printf("%d",j); ) printf(&…
属于水题,主要是涉及到回文问题. 这里标注下进制转换的方法: while(n) { p[i]=n%basis; n/=basis; } 见代码: #include <stdio.h> int revert(int n,int base) { int p[20]; int i=0; while(n) { p[i++]=n%base; n/=base; } int ispar=1; for(int j=0,k=i-1;j<k;j++,k--) { if(p[j]!=p[k]) { ispar…
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not…
------------------------------------------------------------ 以此题警告自己: 总结, 1.在数组的使用时,一定别忘了初始化 2.在两种情况复制代码时,一定要小心,注意修改变量名,一不留神就会带来不可估量的后果,一定要仔细挨着一个一个变量的修改,别跳着看着哪个变量就改哪一个变量! (这个题目中,就是复制了一下,代码,ca,我找了一下午的错....还好终于找到了,一个字母的错,) -----------------------------…
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... By converting each letter in a word to a number corresponding to its alphabetical position and…
题意 : 将从 1 ~ n 的数分成两组,要求两组和的差值尽可能小,并输出其中一组的具体选数情况 分析 : 如果将这 n 个数从大到小四个一组来进行选择的话那么差值就为 0 ,然后再来考虑 n%4 != 0 的情况.举个例子就是 n = 9 的时候,我们考虑 6 7 8 9 ,将6.9放入一组,7.8放入第二组,那么此时差值就会为 0 ,接下来再对 2 3 4 5 进行同样的取法此时差值仍为 0 ,最后剩下一个 1 ,很显然最后的最小差值应当为 1 .其实综合考虑一下 n%4 != 0 的情况只…
题目: 分析: 看到式子,推一推其实就是(y+x)*(y-x)=n,显然可以根号n的枚举,判断一下合不合法直接出结果,然后就是代码.注意x!=0. #include <cstdio> #include <string> using namespace std; int main(){ int t; scanf("%d",&t); for(int i=;i<=t;i++){ int n; scanf("%d",&n); i…
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space and in O(n) runtime?…
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not allowed to contain the digit zero. G…
问题1:打开eclipse,出现了Initializing Java Tooling “has encountered a problem,点开详细信息,报的是空指针异常. 问题2:鼠标悬停在没有导包的类上面不会出现import信息. 此前解决办法:因为电脑上面有几个版本,32位和64的JDK,把JDK环境更改了,才出现此问题,后来修改保存,均无效. 最终解决办法,到eclipse安装目录,运行eclipsec.exe,问题均得到解决:…
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory limit per test 256 megabytes 问题描述 Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his proble…
http://codeforces.com/contest/747/problem/F cf #387 div2 problem f 非常好的一道题.看完题,然后就不知道怎么做,感觉是dp,但是不知道怎么枚举.还有就是一般求第k小的思路一般是什么?对这类题目理解的不是很好. 这道题,跟上一篇的题解里面写的hdu 1002 递增数的题目的解法差不多,但是底层的求解需要花一些时间去推敲! 不会做,就看官方题解,看不懂说的什么.就从下面的讨论找大神的题解. I can describe my solu…
Problem 2 --- Add Two Numbers 简单的模拟题. Problem 3 --- Longest Substring Without Repeating Characters 题意: 给定一个字符串序列,找出最长无重复的子序列.如"abcabcbb"的最长不重复子序列为"abc" 思路: 首先分配一个hashTable[256],里面保存每个字符在当前字符序列中的位置,同时设置left变量表示当前无重复字符串的最左端位置.然后从头到尾扫面字符串…
http://codeforces.com/problemset/problem/47/A Triangular numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A triangular number is the number of dots in an equilateral triangle unifor…
任意门:http://poj.org/problem?id=1320 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3181   Accepted: 1776 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the…