UVA - 11636 Hello World! (贪心)】的更多相关文章

UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r++; printf("Case %d: %d\n",++kas,r); } ; } LA 3602 DNA Consensus String 贪心构造,每一位上选出现次数最多的. #include<bits/stdc++.h> using namespace std; ,ma…
UVA.11636 Hello World! (思维题) 题意分析 这题挺水的,还是错了几发. QWQ. 有一个同学打了一行hello world,现在他想打n行hello world,请问最少复制粘贴几次. 先说说我的XX想法.绝对是中了二进制的邪!样例给给打好呀,如果我想输出4个,那么复制一次,得到2个,再复制一次得到4个.然后就莫名其妙的和二进制连起来了. 十进制----二进制 0----–00000000 1----–00000001 2----–00000010 3----–00000…
uva 1615 高速公路(贪心,区间问题) 给定平面上n个点和一个值D,要求在x轴上选出尽量少的点,使得对于给定的每个点,都有一个选出的点离它的欧几里得距离不超过D.(n<=1e5) 对于每个点,可以找出在x轴上的对应线段,于是这道题就被转换成了一个区间选点问题.将所有线段都按右端点排好序,然后每次将点取在线段的最右端,如果覆盖不到最新线段就再创造一个新点,这样一直贪心的取下去即可. #include <cmath> #include <cctype> #include &…
思路:复制次数最少并且可以部分复制,那么贪心地让当前尽量多的复制,如果最后一次复制会超过n,那就部分复制.即满足并且x尽量小. AC代码 #include <stdio.h> const int maxn = 20; int bit[maxn]; void init() { bit[0] = 1; for(int i = 1; i < maxn; i++) { bit[i] = bit[i-1] * 2; } } int main() { init(); int n, kase = 1;…
题目链接: https://cn.vjudge.net/problem/34398/origin 题目比较简单,就是水题,基础贪心,大于所需的即可: AC代码: 打表: #include <cmath> #include <iostream> #include <cstdio> #define ll long long using namespace std; ; ll mp[MX]; void get_table() //打一个2^n的表即可 { ; i <=…
https://vjudge.net/problem/UVA-11636 题意: 经过一次复制,一条语句会变成两条语句,再经过一次变成四条语句...求最少需要复制几次能使条数恰好为n? 思路: 贪心水题. 每次以最大复制数复制即可. #include<iostream> #include<algorithm> #include<string> using namespace std; + ; int n; int main() { ios::sync_with_stdi…
题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路下木棍时的最大值,和走短路时的就行了. 代码: /* * Author: illuz <iilluzen@gmail.com> * Blog: http://blog.csdn.net/hcbbt * File: uva10714.cpp * Lauguage: C/C++ * Create Da…
"Waiting for orders we held in the wood, word from the front never came By evening the sound of the gunfire was miles away Ah softly we moved through the shadows, slip away through the trees Crossing their lines in the mists in the fields on our hand…
题意:给出一个数N,下限L上限U,在[L,U]里面找一个整数,使得N|M最大,且让M最小. 很明显用贪心,用位运算搞了半天,样例过了后还是WA,没考虑清楚... 然后网上翻到了一个人家位运算一句话解决了 = =....ORZ... 人家的分析:(by天然呆大神) 儘量讓 N 中為 0 的位元,M 為 1:N 為 1 的位元, M 為 0. 因此從高位往低位檢查, 如果 N 為 1(M 儘量為 0),若 M 不能為 0,則必是因為 M 為 1 仍小於 L: 如果 N 為 0(M 儘量為 1),若…
UVA11039-Building designing Time limit: 3.000 seconds An architect wants to design a very high building. The building will consist of some floors, and each floor has a certain size. The size of a floor must be greater than the size of the floor immediate…