题意:使用最小的复制/黏贴次数,使得语句的条数恰好为n
思路:贪心思想,因为复制是所有条数翻倍,所以每次都取最大的条数*2
PS:天真的认为是n = -1时退出,所以WA了好几次。
#include
#include
#include
#include
using namespace std;
int main() {
int n, t = 1;
...
分类:
其他好文 时间:
2014-08-06 23:07:12
阅读次数:
272
package com.peter.app.hello.heapsort;/** * heap sort * @author Peter.Yu * */public class HeapSort { public static int COUNT = 0; /** * build heap * @param a * @param size */ public static void buildHe...
分类:
编程语言 时间:
2014-08-06 19:27:52
阅读次数:
269
1.首先介绍下大家最常用到的:#region与#endregion。该指令用于把一段代码标记为有给定名称的一个块。如下所示:#region Helloint i = 1;string str = "hello";#endregion2.#define与#undef。(必须放在c#源文件的开头位置)#...
分类:
其他好文 时间:
2014-08-06 17:56:41
阅读次数:
140
Python要想调用C语言写的动态连接库,不仅要兼容C接口的调用习惯,还需要兼容C语言的数据类型。幸运的是ctypes库已经做了这两方面的工作,以便调用动态连接库是非常方便的。在Hello World的程序里,这行代码编写如下:MessageBox = windll.user32.MessageBoxW从这行代码的简洁程度来看,是非常优美的。这种优美是由于ctypes库在背后做了非常多的工作,比如...
下面的六个程序片段主要完成这些事情:
输出Hello, World混乱C语言的源代码
下面的所有程序都可以在GCC下编译通过,只有最后一个需要动用C++的编译器g++才能编程通过。
hello1.c
1
2
3
4
5
6
7
8
9
10
11
#define _________ }
#define...
分类:
编程语言 时间:
2014-08-05 19:19:20
阅读次数:
279
Learn some erlang中讲关于TCP,UDP在Erlang中的应用,及使用二进制代替列表的优缺点。
分类:
其他好文 时间:
2014-08-05 19:08:30
阅读次数:
451
计算机程序原文地址#include int main(void) { printf("Hello world!\n"); return 0;}C的Hello World程序样例public class HelloWorld { public static void main(Str...
分类:
其他好文 时间:
2014-08-05 18:42:29
阅读次数:
243
希望在这里留下自己成长的足迹1 public class Hello2 {3 public static void Main()4 {5 Console.WriteLine("hello world!");6 }7 }
分类:
其他好文 时间:
2014-08-05 15:43:09
阅读次数:
205
最近用PHP读取一个大文件把相关数据存放到数组中,之后处理并输出, 读取过程中发现占用内存很大, 于是很好奇这个问题。简单的写一个代码'hello world1', 'testb'=>'hello world2', );$m3 = memory_get_usage();echo ...
分类:
Web程序 时间:
2014-08-05 15:38:29
阅读次数:
176
课后习题7–1. 字典方法。哪个字典方法可以用来把两个字典合并到一起?答:dict1 = {'1' :' python' }dict2 = {'2' :"hello" }dict1.update(dict2)dictAll = dict1print dictAllResult:{'1': ' pyt...
分类:
编程语言 时间:
2014-08-05 15:29:09
阅读次数:
414