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. 深度浅出immutable.js

    这篇文章将讲述immutable.js的基本语法和用法. 1.fromJs()  Deeply converts plain JS objects and arrays to Immutable Ma ...

  2. Dapper学习 - Dapper.Rainbow(二) - Update/Delete

    上一篇介绍了Rainbow的Create方法, 这里就来介绍一下Update方法吧, 毕竟新增和修改是双胞兄弟嘛. 一.Update 1. 测试代码: var conStr = Configurati ...

  3. Web API应用架构设计分析(1)

    Web API 是一种应用接口框架,它能够构建HTTP服务以支撑更广泛的客户端(包括浏览器,手机和平板电脑等移动设备)的框架, ASP.NET Web API 是一种用于在 .NET Framewor ...

  4. 新浪微博.Net SDK第三版源代码和示例【最后一次更新了】

    时间过得飞快,距离上次SDK更新已经3年有余.随着官方的不断跟新,老版SDK的部分接口已经不能正常使用.因此在QQ群里来吐槽的.来谩骂的朋友也开始多了起来.随着时代的发展,微博已经彻底的被微信甩开,因 ...

  5. 修复一个吉日嘎拉MSSQL数据库版中的分页存储过程bug

    这个存储过程是3.7以来一直存在,并未针对MSSQL2005以上版本进行ROW_NUMBER() OVER升级,还是延续TOP的写法.这并非是我所谓的bug,我所说的bug是指执行了排序的字段,如果字 ...

  6. MVC部分视图的巧用

    View视图界面 @{ Html.RenderAction("demo", "", new { id = ViewBag.id });} 请求的控制器方法 pu ...

  7. Retrieving Out Params From a Stored Procedure With Python

    http://www.rodneyoliver.com/blog/2013/08/08/retrieving-out-params-from-a-stored-procedure-with-pytho ...

  8. Firemonkey TComboBox 下拉菜单字型修改方法 (D10)

    在 FMX 下的 TComboBox 下拉菜单字型修改有二种方法: uses FMX.Pickers; 使用 Style,需先设定好 Style 后,再指定预设项的 Style,方法如下: proce ...

  9. 容器--EnumMap

    一.概述 EnumMap是一类特殊的Map, 其特殊之处在于KEY需要是枚举类型,由于枚举类型的特点是值的个数是固定的,所以,对于EnumMap来说,其所能存储的个数也就是固定的了.这种类型的Map相 ...

  10. Mysql新增用户,权限管理

    MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant selec ...