详解:hdu 1907 John - lihaogegehuting的专栏 - 博客频道 - CSDN.NET
两道题几乎一样
代码如下:
#include
int main()
{
int T,a[100],i,sum,ok;
while(~scanf("%d",&T))
{
sum=0;
ok=0;
...
js性能优化
javascript是一种解释型语言,性能无法达到和C、C++等编译语言的水平,但还是有一些方法来改进。
1、循环
JavaScript中的循环方式有for(;;)、while()、for(in)3种。其中for(in)的效率极差,因为for(in)执行过程中需要查询散列键。for(;;)和while()比较,while循环的效率要优于for(;;)。
2、局部...
分类:
Web程序 时间:
2014-07-29 15:05:09
阅读次数:
354
#include
int n,a[100005];
int main()
{
int i,j,h;
bool bo=true;
scanf("%d",&n);
for (i=0;i<n;i++)scanf("%d",&a[i]);
i=0;
while (a[i]<=a[i+1]&&i<n-1) i++;...
分类:
其他好文 时间:
2014-07-29 14:50:28
阅读次数:
198
计算一个字符串数组中有多少个重复字符串出现。
如果直接使用map容器,那么这条题就很简单了,一下就AC了,因为map已经处理好一切了;
不过时间超过1532ms,有点慢。
如下:
int main()
{
map msi;
int total = 0;
char treeName[40];
while (gets(treeName))
{
msi[treeName]++;
...
分类:
其他好文 时间:
2014-07-29 14:32:18
阅读次数:
288
session.BeginDataAccess(); if (session.GotoFirstSource()){ do{ RTPPacket *packet; while ((packet = session.GetNextPacket()) != 0){ ...
分类:
其他好文 时间:
2014-07-29 14:12:48
阅读次数:
282
bash支持下述流程控制结构:
if/else:如果某条件为真/假,执行一个执行列表。
for:执行一个语句列表固定次数。
while:当某条件为真时重复执行某语句列表
until:重复执行某语句列表直至某条件为真。
case:依据一个变量取值执行几个语句列表中的一个。
select:允许用户从一个菜单的可选列表中选择一个。...
分类:
其他好文 时间:
2014-07-29 13:13:17
阅读次数:
251
贪心
#include
using namespace std;
int main()
{
long long n;
char s[100020];
while(scanf("%I64d",&n)==1)
{
scanf("%s",s);
int len=strlen(s);
long long sum1=0,sum...
分类:
其他好文 时间:
2014-07-29 13:07:36
阅读次数:
192
长为H的格子里面放n个长为h的格子 最多会有n+1个空隙
要使每个空隙长度都小于h (H-h*n)/(n+1)
n>(H/h-1)/2
#include
int main()
{
int W,H,w,h;
while(scanf("%d%d%d%d",&W,&H,&w,&h)==4)
{
int x=(int)ceil((W*1.0/w-1)/2),y...
分类:
其他好文 时间:
2014-07-29 13:04:57
阅读次数:
215
代码:#include #include int main(){ int t; while(scanf("%d",&t)!=EOF) { while(t--) { __int64 n; scanf("%I64d",&n); double x=n*log10(n*1.0); x-=(__int64)x...
分类:
其他好文 时间:
2014-07-29 12:34:57
阅读次数:
229
题目:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.F....
分类:
编程语言 时间:
2014-07-29 12:33:16
阅读次数:
323