51nod1010(枚举+二分)】的更多相关文章

题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 题意:中文题诶- 思路:求第一个比 x (1<=x<=1e18)大或者等于的数y, 且y的因子只有2, 3, 5,即y=pow(2, i)*pow(3, j)*pow(5, k); 那么显然我们可以通过枚举i, j, k求出所有由2, 3, 5因子构成的数,并将其存入数组中,再二分查找数组中第一个大于等于x的数即为答案: 代码: #include &…
Yukari's Birthday  HDU4430 就是枚举+二分: 注意处理怎样判断溢出...(因为题目只要10^12) 先前还以为要用到快速幂和等比数列的快速求和(但肯定会超__int64) 而且这样判断会超时的... 还有题目中的And it's optional to place at most one candle at the center of the cake. (中间的蜡烛可有可无) 还有观察数据就知道:因为n最大10^12,r最多枚举到40,然后二分k的结果,看是否有符合条…
1514: Packs Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 61  Solved: 4[Submit][Status][Web Board] Description Give you n packs, each of it has a value v and a weight w. Now you should find some packs, and the total of these value is max, total of…
The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0 . In the following, we assume that all lists have the same size n .…
C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a…
题意:问方程X^Z + Y^Z + XYZ = K (X<Y,Z>1)有多少个正整数解 (K<2^31) 解法:看K不大,而且不难看出 Z<=30, X<=sqrt(K), 可以枚举X和Z,然后二分找Y,这样的话不把pow函数用数组存起来的话好像会T,可以先预处理出1~47000的2~30次幂,这样就不会T了. 但是还可以简化,当Z=2时,X^2+Y^2+2XY = (X+Y)^2 = K, 可以特判下Z= 2的情况,即判断K是否为平方数,然后Z就可以从3开始了,这样的话X^…
题目链接:http://poj.org/problem?id=3977 给你n个数,找到一个子集,使得这个子集的和的绝对值是最小的,如果有多种情况,输出子集个数最少的: n<=35,|a[i]|<=10e15 子集个数共有2^n个,所以不能全部枚举,但是可以分为两部分枚举: 枚举一半的所有情况,然后后一半二分即可: #include<iostream> #include<algorithm> #include<string.h> #include<st…
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i=1n∑j=inf(i,j) mod (109+7).   Input There are m…
题目链接: B. Skills time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was…
传送:http://codeforces.com/gym/101612 题意:给定一个数n(<=1e18),将n分解为若干个数的成绩.要求这些数两两之间的差值不能大于1. 分析: 若n==2^k,则答案一定是-1. 然后,考虑若n==a^k,枚举k,二分求a.若n==a^x*(a+1)^y,枚举x,y,二分求解a. 注意:两数相乘可能>1e18,特判. #include<bits/stdc++.h> using namespace std; typedef long long ll…