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. js基础篇——encodeURI 和encodeURIComponent

    转自zccst的又一次掉进encodeURIComponent的坑里了 问题: ajax.get ( url+'?k1'=v1+'&k2'=v2+'&k3'=v3, ... ); 由于 ...

  2. 基于HTML5的WebGL结合Box2DJS物理应用

    上篇我们基于HT for Web呈现了A* Search Algorithm的3D寻路效果,这篇我们将采用HT for Web 3D来呈现Box2DJS物理引擎的碰撞效果,同上篇其实Box2DJS只是 ...

  3. 扩展Exception,增加判断Exception是否为SQL引用约束异常方法!

    在设计数据表时,如果将某些列设置为关联其它表的外键,那么如果对其进行增加.修改操作时,其关联表若没有相匹配的记录则报错,或者在对其关联表进行删除时,也会报错,这就是外键约束的作用,当然除了外键还有许多 ...

  4. HTML语义化:HTML5的新标签及IE5.5~9的部分兼容方案

    一.前言 本文将介绍HTML5中新增的语义化标签,及在IE5.5~9(IE9已经开始支持部分HTML5新标签了)支持这些新标签的兼容性处理. 目录一坨: 二.语义化标签:article.aside.t ...

  5. noip模拟赛 纸壳子

    Task 1.纸壳子(box.pas/box.c/box.cpp) [题目描述] Mcx是一个有轻度洁癖的小朋友.有一天,当他沉溺于数学卷子难以自拔的时候,恍惚间想起在自己当初学习概率的时候准备的一堆 ...

  6. 使用Python将Excel中的数据导入到MySQL

    使用Python将Excel中的数据导入到MySQL 工具 Python 2.7 xlrd MySQLdb 安装 Python 对于不同的系统安装方式不同,Windows平台有exe安装包,Ubunt ...

  7. 一个故事讲清楚NIO

    转载请引用:一个故事讲清楚NIO 假设某银行只有10个职员.该银行的业务流程分为以下4个步骤: 1) 顾客填申请表(5分钟): 2) 职员审核(1分钟): 3) 职员叫保安去金库取钱(3分钟): 4) ...

  8. 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native

    [源码下载] 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native 作者:web ...

  9. Tigase数据库结构(1)

    Tigase数据库有很多张表,其中最主要的是3张表:tig_users,tig_nodes和tig_pairs. 1.tig_users tig_users存储用户信息,有uid(主键,用户ID),u ...

  10. VirtualBox网络设置的问题

    在VirtualBox里新建了一个虚拟Linux系统,默认的连接方式是网络地址转换(NAT).发现主机不能访问虚拟机的samba服务器,ping了一下,虚拟机可以ping主机,但是主机不能ping虚拟 ...