1001--Sum Problem(http://acm.hdu.edu.cn/showproblem.php?pid=1001

#include <stdio.h>

int sum(int n)
{
if(n % )
return (n + ) / * n;
else
return (n / ) * (n + );
} int main()
{
int n;
while(scanf("%d",&n) != EOF){
printf("%d\n\n",sum(n));
}
return ;
}

1002--A + B Problem II(http://acm.hdu.edu.cn/showproblem.php?pid=1002

简单题:大数的运算

注意格式(Case的首字母大写、各种空格、每一行之间有空行,最后一行没有空行)!

给出几组测试数据:

6

1 2
1 0
9999 1
1 999999
5555 4445
112233445566778899 998877665544332211
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void solve()
{
int n,i,j,k,flag,t,cas,L;
char a[],b[],c[];
scanf("%d",&n);
getchar();
cas=;
while(n--)
{
flag=;
memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
memset(c,'\0',sizeof(c));
scanf("%s",a);
scanf("%s",b);
printf("Case %d:\n",cas);
printf("%s",a);
printf(" + ");
printf("%s",b);
printf(" = ");
strrev(a);
strrev(b);
k=i=;
L=(strlen(a)>strlen(b)?strlen(b):strlen(a));
while(i<L)
{
t=(a[i]-'')+(b[i]-'')+flag;
flag=(t>=?:);
c[k++]=t%+'';
i++;
}
if(a[i]=='\0')
{
while(b[i]!='\0') {
t=b[i++]-''+flag;
c[k++]=t%+'';
flag=(t>=?:);
}
}
else
{
while(a[i]!='\0') {
t=a[i++]-''+flag;
c[k++]=t%+'';
flag=(t>=?:);
}
}
if(flag) c[k]='';
else k--;
while(k>=)
{
printf("%c",c[k]);
k--;
}
printf("\n");
if(n>) printf("\n");
cas++;
}
} int main()
{
solve();
return ;
}

1003--Max Sum(http://acm.hdu.edu.cn/showproblem.php?pid=1003

#include<iostream>
#include<cstdio>
using namespace std; void solve()
{
int T, i, max,sum,n,num,begin,end,t,con;
while(cin>>T) {
for(i = ; i <= T; i++) {
max = -;
sum = ;
n = con = ;
cin>>n;
num = n;
begin = end = ;
while(n--) {
cin>>t;
sum += t;
con++;
if(sum > max) {
begin = con;
max = sum;
end = num - n;
}
if(sum < ) {
sum = ;
con = ;
}
}
cout<<"Case "<<i<<":"<<endl<<max<<" "<<end-begin+<<" "<<end<<endl;
if(i != T) cout<<endl;
}
}
} int main()
{
solve();
return ;
}

1004--Let the Balloon Rise(http://acm.hdu.edu.cn/showproblem.php?pid=1004

#include<iostream>
#include<cstdio>
#include<map>
#include<string>
#include<cstring>
using namespace std; void solve()
{
int T, max, t;
map<string, int> color_count;
string color;
while(cin>>T && T) {
max = ;
while(T--) {
cin>>color;
++color_count[color];
}
map<string, int>::const_iterator ii, it;
it = color_count.begin();
while(it != color_count.end()) {
if(max < it->second) {
max = it->second;
ii = it;
}
it++;
}
cout<<ii->first<<endl;
color_count.clear();
}
} int main()
{
solve();
return ;
}

1005--Number Sequence(http://acm.hdu.edu.cn/showproblem.php?pid=1005

#include<iostream>
using namespace std; void solve()
{
int A, B, n;
while(cin>>A>>B>>n && (A || B || n)) {
int a[] = {, };
for(int i = ; i < (n % - ) / ; i++) {
a[] = (A * a[] + B * a[]) % ;
a[] = (A * a[] + B * a[]) % ;
}
if(n % ) {
cout<<a[]<<endl;
} else {
cout<<a[]<<endl;
}
}
} int main()
{
solve();
return ;
}

HDOJ1001-1005题解的更多相关文章

  1. PAT 乙级 1005

    题目 题目地址:PAT 乙级 1005 题解 本题主要就在于将一个数的一系列计算结果不重复地存储起来并便于检索,考虑到STL中的集合有相似的特性,使用set可以有效地简化代码和运算. 过程如下: (初 ...

  2. Leetcode题解 - 贪心算法部分简单题目代码+思路(860、944、1005、1029、1046、1217、1221)

    leetcode真的是一个学习阅读理解的好地方 860. 柠檬水找零 """ 因为用户支付的只会有5.10.20 对于10元的用户必须找一个5 对于20元的用户可以找(三 ...

  3. 题解西电OJ (Problem 1005 -跳舞毯)--动态规划

    Description zyf不小心得了一种怪病,为了维持一天的精力他必须不停跳动.于是他买了一条跳舞毯,每天跳上几小时.众所周知,跳舞毯是给定一个序列,让你在指定时间踏指定的按钮,但zyf似乎不怎么 ...

  4. PAT甲题题解-1005. Spell It Right (20)-数位求和,水

    把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 #include <iostream> #include <cstdio> #include <alg ...

  5. Light OJ 1005 - Rooks 数学题解

    版权声明:本文作者靖心.靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...

  6. 【实(dou)力(bi)首(mai)发(meng)】第四次CCF软件能力认证题解

    这次的题总体上相对前三次偏简单.由于实力有限,就分析前四题.     试题编号:    201503-1 试题名称:    图像旋转 时间限制:    5.0s 内存限制:    256.0MB 问题 ...

  7. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

  8. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  9. BestCoder Round #60 题解链接

    题解  题目 1001 GT and sequence 注意先特判000的情况:如果读入的数据有000,那么去掉所有的000且最后答案和000取一个max. 剩下的正数显然全部乘起来比较优. 对于负数 ...

  10. 递推DP 赛码 1005 Game

    题目传送门 /* 递推DP:官方题解 令Fi,j代表剩下i个人时,若BrotherK的位置是1,那么位置为j的人是否可能获胜 转移的时候可以枚举当前轮指定的数是什么,那么就可以计算出当前位置j的人在剩 ...

随机推荐

  1. 《淘宝技术这十年》之LAMP架构的网站

    本文节选自<淘宝技术这十年>一书,子柳(赵超)著,由电子工业出版社出版.作者的系列博文:从P1到P7--我在淘宝这7年 2003年4月7日,马云在杭州成立了一个神秘的组织.他叫来十位员工, ...

  2. 【Swift学习】Swift编程之旅---闭包(十一)

    闭包是可以在代码中被传递和使用的自包含功能模块,它很像c和oc中的block,和.net中的lambdasbas表达式. 闭包可以捕获和存储其所在上下文中任意常量和变量的引用. 包裹着这些常量和变量的 ...

  3. 将RichTextBox的内容直接写入数据库:

    将RichTextBox的内容直接写入数据库: private void button1_Click(object sender, EventArgs e) {    System.IO.Memory ...

  4. 【原创】Kakfa message包源代码分析

    笔者最近在研究Kafka的message包代码,有了一些心得,特此记录一下.其实研究的目的从来都不是只是看源代码,更多地是想借这个机会思考几个问题:为什么是这么实现的?你自己实现方式是什么?比起人家的 ...

  5. 【转载】8天学通MongoDB——第四天 索引操作

    这些天项目改版,时间比较紧,博客也就没跟得上,还望大家见谅. 好,今天分享下mongodb中关于索引的基本操作,我们日常做开发都避免不了要对程序进行性能优化,而程序的操作无非就是CURD,通常我们 又 ...

  6. 基于<MediaElement>的WPF视频播放器(带部分特效)【2】

    一.前言       上回说到需要做放视频的使用向导,这两天公司里的老司机一直帮我答疑解惑,让这个任务变得挺顺的,真心感谢他们! 这次与[1]中的不同之处在于: (1)播放和暂停按钮集成在<Me ...

  7. 史上最全系列Android开发环境搭建

    一.安装JDK1.JDK下载打开网站http://www.oracle.com/technetwor ... nloads-1880260.html,选择相应的操作系统下载JDK 2.安装JDK本机是 ...

  8. 用 Inkspace 做 SVG 给 TPath

    FireMonkey 里的 TPathData 支持 SVG 的基本绘图指令,因此可以运用 Inkspace 软件,提取 SVG 的绘图内容,请见图片说明:

  9. 求助,eclipse总是卡在building workspace-CSDN论坛

    1).解决方法 方法1.修改eclipse启动文件 eclipse.ini 中添加启动参数参数: -vmargs -Xmx512m 方法2.关闭自动构建工作区: project -> build ...

  10. java之StringBuffer类详解

    StringBuffer 线程安全的可变字符序列. StringBuffer源码分析(JDK1.6): public final class StringBuffer extends Abstract ...