Ice_cream’s world III(prime)】的更多相关文章

Ice_cream’s world III Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 6   Accepted Submission(s) : 3 Problem Description ice_cream’s world becomes stronger and stronger; every road is built as un…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25165   Accepted: 7751 Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are t…
素数的判断: #include<math.h> bool IsPrime(int n) { ) return false; int sqr = (int)sqrt(1.0*n); ; i<=sqr; i++) ) return false; return true; } 获取素数表: ; vector<int> prime; }; void FindPrime() { ; i<M; i++) if(IsPrime(i)) { prime.push_back(i); is…
题目 Table: Activity +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +--------------+---------+ (player_id,event_date)是此表的主键. 这张表显示了某些游戏的玩…
题意: N=a[1]+a[2]+a[3]+...+a[m];  a[i]>0,1<=m<=N; 例如: 4 = 4;  4 = 3 + 1;  4 = 2 + 2;  4 = 2 + 1 + 1;  4 = 1 + 1 + 1 + 1; 共有5种. 给N,问共有几种构造方式. 思路: 一个数N分解的式子中1的个数可以是0,1,2,3,...,N. 2的个数可以是0,1,2,...,N/2. .... 母函数基础题,, 看代码. 当然也可以用DP(背包) 母函数代码: int N,num;…
2坑,3次WA. 1.判断重边取小.2.自边舍去. (个人因为vis数组忘记初始化,WA了3次,晕死!!) #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <numeric> #d…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20918    Accepted Submission(s): 14599 Problem Description "Well, it seems the first problem is too easy. I will let…
题目链接:5198. 丑数 III 请你帮忙设计一个程序,用来找出第 n 个丑数. 丑数是可以被 a 或 b 或 c 整除的 正整数. 示例 1: 输入:n = 3, a = 2, b = 3, c = 5 输出:4 解释:丑数序列为 2, 3, 4, 5, 6, 8, 9, 10- 其中第 3 个是 4. 示例 2: 输入:n = 4, a = 2, b = 3, c = 4 输出:6 解释:丑数序列为 2, 3, 4, 6, 8, 9, 12- 其中第 4 个是 6. 示例 3: 输入:n…
437. 路径总和 III 给定一个二叉树,它的每个结点都存放着一个整数值. 找出路径和等于给定数值的路径总数. 路径不需要从根节点开始,也不需要在叶子节点结束,但是路径方向必须是向下的(只能从父节点到子节点). 二叉树不超过1000个节点,且节点数值范围是 [-1000000,1000000] 的整数. 示例: root = [10,5,-3,3,2,null,11,3,-2,null,1], sum = 8 10 / \ 5 -3 / \ \ 3 2 11 / \ \ 3 -2 1 返回 3…
337. 打家劫舍 III 在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区.这个地区只有一个入口,我们称之为"根". 除了"根"之外,每栋房子有且只有一个"父"房子与之相连.一番侦察之后,聪明的小偷意识到"这个地方的所有房屋的排列类似于一棵二叉树". 如果两个直接相连的房子在同一天晚上被打劫,房屋将自动报警. 计算在不触动警报的情况下,小偷一晚能够盗取的最高金额. 示例 1: 输入: [3,2,3,nu…
123. 买卖股票的最佳时机 III 给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格. 设计一个算法来计算你所能获取的最大利润.你最多可以完成 两笔 交易. 注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票). 示例 1: 输入: [3,3,5,0,0,3,1,4] 输出: 6 解释: 在第 4 天(股票价格 = 0)的时候买入,在第 6 天(股票价格 = 3)的时候卖出,这笔交易所能获得利润 = 3-0 = 3 . 随后,在第 7 天(股票价格 = 1)的…
这个题要交c++, 因为prime的返回值错了,改了一会 题目:http://poj.org/problem?id=2031 题意:就是给出三维坐标系上的一些球的球心坐标和其半径,搭建通路,使得他们能够相互连通.如果两个球有重叠的部分则算为已连通,无需再搭桥.求搭建通路的最小费用(费用就是边权,就是两个球面之间的距离 思路:求球之间的距离, 距离小于半径 说明联通 , 距离为0. #include<iostream> #include<cstdio> #include<cst…
转自:http://www.cnblogs.com/destino74/p/3960802.html 条款5:Know what functions C++ silently writes and calls 译:了解C++默默编写并调用哪些函数 在C++中,写一个空类,编译器会自动为它声明一个copy构造函数.一个copy assignment操作符和一个析构函数.如果没有声明任何构造函数,编译器也会自动声明一个default构造函数. 如下: class Empty{}; 这就相当于 cla…
传送门 Description Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given nums = [1, 2, 1, 3, 2, 5], return [3, 5].…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9532    Accepted Submission(s): 6722 Problem Description "Well, it seems the first problem is too easy. I will let y…
Tree Time Limit : 6000/2000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 2   Accepted Submission(s) : 2 Problem Description There are N (2<=N<=600) cities,each has a value of happiness,we consider two cities A and…
26 <万年坑系列> I:那些令你憎恶的系统从何而来? 世界上总有一些令人憎恶的系统,而你却天天非用不可.这些系统的提供方们既不缺钱也不缺人,有的还很热衷于改版升级. 但为何升级完后,它们依旧令人憎恶? 27 <万年坑系列> II:那些令你憎恶的系统到底是谁开发的? 世界上总有一些令人憎恶的系统,而你却天天非用不可.这些系统的提供方们既不缺钱也不缺人,有的还很热衷于改版升级,可是越升级往往越烂那么,到底是谁在开发这些系统? 28 <万年坑系列> III:那些令你憎恶的系…
描述 Diablo III is an action role-playing video game. A few days ago, Reaper of Souls (ROS), the new expansion of Diablo III, has been released! On hearing the news, the crazy video game nerd Yuzhi shouted: "I'm so excited! I'm so excited! I wanna kill…
Truck History Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 31871   Accepted: 12427 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bric…
组合总和 III 找出所有相加之和为 n 的 k 个数的组合.组合中只允许含有 1 - 9 的正整数,并且每种组合中不存在重复的数字. 说明: 所有数字都是正整数. 解集不能包含重复的组合.  示例 1: 输入: k = 3, n = 7 输出: [[1,2,4]] 示例 2:   输入: k = 3, n = 9 输出: [[1,2,6], [1,3,5], [2,3,4]]     思路:做过前面的组合总数I.II之后,会觉得这道题得心应手.一样的套路,唯一需要变化的是在for循环中的初始值…
Building a Space Station Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6635   Accepted: 3236 Description You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You ar…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16242    Accepted Submission(s): 11445 Problem Description "Well, it seems the first problem is too easy. I will le…
260. 只出现一次的数字 III 给定一个整数数组 nums,其中恰好有两个元素只出现一次,其余所有元素均出现两次. 找出只出现一次的那两个元素. 示例 : 输入: [1,2,1,3,2,5] 输出: [3,5] 注意: 结果输出的顺序并不重要,对于上面的例子, [5, 3] 也是正确答案. 你的算法应该具有线性时间复杂度.你能否仅使用常数空间复杂度来实现? PS: 1.两个相同的数异或结果为0 2.任意数异或0都为任意数 3.按位异或不同则为1,相同则为0 class Solution {…
216. 组合总和 III 找出所有相加之和为 n 的 k 个数的组合.组合中只允许含有 1 - 9 的正整数,并且每种组合中不存在重复的数字. 说明: 所有数字都是正整数. 解集不能包含重复的组合. 示例 1: 输入: k = 3, n = 7 输出: [[1,2,4]] 示例 2: 输入: k = 3, n = 9 输出: [[1,2,6], [1,3,5], [2,3,4]] class Solution { //结果集 public List<List<Integer>>…
1. Description The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized tha…
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Ensure that numbers within the set are sorted in ascending order. Example 1…
题目大概说一个平面上分布n个灰尘,现在要用一个宽w的刷子清理灰尘:选择一个起点,往水平线上扫过去这个水平线上的灰尘就消失了.问最多进行k次这样的操作能清理最多多少灰尘. 没什么的DP. 先按垂直坐标给灰尘们排个序, 然后d[i][k]表示前i个灰尘中,进行到第k次清理操作时刷子底部在第i个灰尘的竖坐标能清理的最多灰尘, 最后转移一个一个往前枚举就OK了,规模很小. #include<cstdio> #include<cstring> #include<algorithm>…
题意: 在1-9这9个数字中选择k个出来,若他们的和为n,则加入答案序列,注意升序. 思路: 用DFS的方式,每次决定一个数字,共决策k次.假设上个决策是第i位为5,那么i+1位的范围就是6-9. class Solution { public: vector<vector<int>> combinationSum3(int k, int n) { vector<vector<int>> ans; vector<); DFS(ans,num,k,,,,…
You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the trail. Input Input starts with an integer T (≤ 10000)…
You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the trail. Input Input starts with an integer T (≤ 10000)…