T1000

 #include <stdio.h>
int main()
{
int a, b;
while (scanf("%d %d", &a, &b) != EOF)
printf("%d\n", a + b);
return ;
}

T1001

 #include <stdio.h>
#ifdef AUTHOR
Code By Hatsuakira Tenan
#endif
int f(int n)
{
int js = ;
for (; n > ; --n)
js += n;
return js;
}
int main()
{
int n;
while (scanf("%d", &n) != EOF)
printf("%d\n\n", f(n));
return ;
}

T1002

 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#define MAXLENGTH 1002
#define MAXCARRY 10000
#ifdef AUTHOR
Code By Hatsuakira Tenan
#endif
struct largeint
{
int num[MAXLENGTH], len;
largeint()
{
len = ;
memset(num, , sizeof(num));
}
};
void scanf_override(largeint &input)
{
int tmplen;
char tmp[MAXLENGTH];
scanf("%s", tmp);
std::reverse(tmp, tmp + (tmplen = strlen(tmp)));
input.len = tmplen / + (tmplen % > );
for (int i = , j = ; i < tmplen; ++i, ++j)
{
input.num[j] = tmp[i] - '';
if (tmp[++i] == '\0')
break;
input.num[j] += * (tmp[i] - '');
if (tmp[++i] == '\0')
break;
input.num[j] += * (tmp[i] - '');
if (tmp[++i] == '\0')
break;
input.num[j] += * (tmp[i] - '');
}
}
inline largeint operator +(largeint a, largeint b)
{
int tmp = ;
a.len = std::max(a.len, b.len);
for (int i = ; i < a.len; ++i)
{
a.num[i] += b.num[i] + tmp;
tmp = a.num[i] / MAXCARRY;
a.num[i] %= MAXCARRY;
}
if (tmp > )
a.num[a.len++] = ;
return a;
}
void printf_override(largeint output)
{
printf("%d", output.num[--output.len]);
for (int i = output.len - ; i > -; --i)
printf("%04d", output.num[i]);
}
void work(int k)
{
largeint a = largeint(), b = largeint();
scanf_override(a);
scanf_override(b);
printf("Case %d:\n", k + );
printf_override(a);
printf(" + ");
printf_override(b);
printf(" = ");
a = a + b;
printf_override(a);
printf("\n");
}
int main()
{
int T;
scanf("%d", &T);
work();
for (int i = ; i < T; ++i)
{ printf("\n"); work(i); }
return ;
}

T1003

最长连续子序列和, 根据数据范围(N<=100, 000 & T<=20)选择使用O(n)的算法, 是较为基础的动态规划.

 #include <stdio.h>
#include <limits.h>
#define MAXLENGTH 100005
#ifdef AUTHOR
Code By Hatsuakira Tenan
#endif
int number[MAXLENGTH], start, end, max;
void dp(int length)
{
int max_tmp = , start_tmp = , end_tmp = ;
max_tmp = max = INT_MIN;
for (int i = ; i < length; ++i)
{
if (max_tmp < )
{
if (number[i] > max_tmp)
{
max_tmp = number[i];
start_tmp = end_tmp = i;
if (max < max_tmp)
{
max = max_tmp;
start = start_tmp;
end = end_tmp;
}
}
}
else
{
max_tmp += number[i];
end_tmp = i;
if(max_tmp > max)
{
max = max_tmp;
start = start_tmp;
end = end_tmp;
}
}
}
}
void work(int R)
{
printf("Case %d:\n", R);
int n;
scanf("%d", &n);
for (int i = ; i < n; ++i)
scanf("%d", &number[i]);
dp(n);
printf("%d %d %d\n", max, start + , end + );
}
int main()
{
int T;
scanf("%d", &T);
for (int i = ; i < T; printf("\n"), ++i)
work(i);
work(T);
return ;
}

T1004 用STL 做这个题很耍赖, 但是鉴于数据量不大所以直接暴力遍历也是可以的.

 #include <stdio.h>
#include <string.h>
#include <map>
#include <string>
using std::map;
using std::string;
map<string, int> set;
void work(int n)
{
set.clear();
int maxn = -;
string tmp_stl_string;
char tmp_string[];
for (int i = ; i < n; tmp_stl_string = tmp_string, ++set[tmp_stl_string], ++i)
scanf("%s", tmp_string);
for (map<string, int>::iterator it = set.begin(); it != set.end(); ++it)
if (maxn < it -> second)
{
maxn = it -> second;
tmp_stl_string = it -> first;
}
printf("%s\n", tmp_stl_string.c_str());
}
int main()
{
int n;
scanf("%d", &n);
while (n > )
{
work(n);
scanf("%d", &n);
}
return ;
}

HDOJ(~1004)的更多相关文章

  1. hdoj 1004 学习思路

    hdoj 1004题目大概讲的是,将输入的字符串根据输入次数多少,输出出现次数最多的字符串. 题目逻辑很简单,就是需要选择相应的数据结构,看了别人提交的discuss,明显发现可以使用多种数据结构解这 ...

  2. HDOJ 1004 Let the Balloon Rise

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  3. HDOJ 1004题 Let the Balloon Rise strcmp()函数

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  4. HDOJ 1004 Let the Balloon Rise (字符串+stl)

    题目: Problem Description Contest time again! How excited it is to see balloons floating around. But t ...

  5. 杭电hdoj题目分类

    HDOJ 题目分类 //分类不是绝对的 //"*" 表示好题,需要多次回味 //"?"表示结论是正确的,但还停留在模块阶 段,需要理解,证明. //简单题看到就 ...

  6. 模拟+思维 HDOJ 5319 Painter

    题目传送门 /* 题意:刷墙,斜45度刷红色或蓝色,相交的成绿色,每次刷的是连续的一段,知道最终结果,问最少刷几次 模拟+思维:模拟能做,网上有更巧妙地做法,只要前一个不是一样的必然要刷一次,保证是最 ...

  7. HDOJ 题目分类

    HDOJ 题目分类 /* * 一:简单题 */ 1000:    入门用:1001:    用高斯求和公式要防溢出1004:1012:1013:    对9取余好了1017:1021:1027:   ...

  8. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

随机推荐

  1. 面向站长和网站管理员的Web缓存加速指南

    详细了解HTTP缓存控制及为什么要缓存. 英文版: http://www.mnot.net/cache_docs/ 中文版:http://www.chedong.com/tech/cache_docs ...

  2. WPF 显示模态窗口和窗体

    <WPF编程宝典——使用C# 2008和.NET 3.5(第2版)>第25章与Windows窗体的互操作,本章将介绍用于集成Windows窗体和WPF内容的不同策略.还将分析如何在应用程序 ...

  3. UVA 11737 Extreme Primitive Society

    非常容易的一个题: 只要判断两种基因相差的最小值就行: #include<cstdio> #include<cstring> #include<algorithm> ...

  4. 关于安装完Node.js 出现node is not dedined 问题

    今天想来接触下Node.js 神奇  怀着揣揣的心 从官网下载了windows 的64位mis版本  几个下一步就顺利安装完毕了 接着跟着新手教程走  不懂教程里的 苹果shell 是什么 反正就是检 ...

  5. ANDROID_MARS学习笔记_S02_011_ANIMATION_LayoutAnimationController

    一.简介 二.代码1.xml(1)activity_main.xml <ListView android:id="@id/android:list" android:layo ...

  6. RunTime报错的一个原因,以及截图

    const char * handle; handle = m_conn->openFile(szRemoteFile,"writeOnly","createTru ...

  7. input checkbox问题和li里面包含checkbox

    <input type="checkbox" id="checkbox1"/> $("input#checkbox1").cli ...

  8. java1.8的几大新特性(二)

    七.Date APIJava 8 在包java.time下包含了一组全新的时间日期API.新的日期API和开源的Joda-Time库差不多,但又不完全一样,下面的例子展示了这组新API里最重要的一些部 ...

  9. Item Import: What Does "Sync" Items Do? (Doc ID 417887.1)

    In this Document Goal Solution APPLIES TO: Oracle Item Master - Version 11.5.10.0 to 11.5.10.0 [Rele ...

  10. Android开发UI之给ListView设置布局动画效果

    1.通过JAVA代码添加,资源文件基本上不修改 XML文件,只添加了一个ListView,就不贴XML文件的代码了. java代码: public class MainActivity extends ...