自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 资源 (1)
  • 收藏
  • 关注

原创 题目1510:替换空格

#include#includechar str[1000000]; int main(){ while(gets(str)){ int count=0,i,j; int len=strlen(str); for(i=0;i<len;i++){ if(str[i]==' ') count++; }

2014-07-16 17:40:11 255

原创 剑指offer 1384 二维数组中的查找

#include int binary_search(int a[],int l,int r,int t){ int begin=l; int end=r; while(begin<=end){ int mid=(begin+end)/2; if(t==a[mid]) return 1; else if(t<a[mid])

2014-07-16 16:22:32 272

原创 hdu 1425 sort

http://acm.hdu.edu.cn/showproble#includeint m,n;const int N=1000005;int a[N];int quicksort(int l,int r){ if(l<r){ int low=l; int high=r; int x=a[l]; while(low<high){ while(lo

2014-06-18 22:55:10 285

原创 hdu 1060 Leftmost Digit

http://acm.hdu.edu.cn/showproblem.php?pid=1060m=n^n;两边同取对数,得到,log10(m)=n*log10(n);再得到,m=10^(n*log10(n));然后,对于10的整数次幂,第一位是1,所以,第一位数取决于n*log10(n)的小数部分#include #include int main(){

2013-07-26 19:44:40 296

原创 hdu 1286 找新朋友

http://acm.hdu.edu.cn/showproblem.php?pid=1286#include #include int main(){ int a[40000],T,i; while(scanf("%d",&T)!=EOF){ while(T--){ memset(a,0,sizeof(a)); int n,count=0;

2013-07-26 15:46:21 283

原创 hdu 1215 七夕节

http://acm.hdu.edu.cn/showproblem.php?pid=1215主要问题在于容易超时。。。#include #include int main(){ int T,m; while(scanf("%d",&T)!=EOF){ while(T--){ scanf("%d",&m); int t,sum=1;

2013-07-14 22:59:49 349

原创 hdu 1722 Cake

点击打开链接开始没什么思路,看了别人的博客才豁然开朗,有思路代码就很简单了,把蛋糕分成p块,再拼在一起分成q块,分成p块需切p刀,分成p块需切p刀,拼在一起则需减去公共部分,即需切p+q-gcd(p,q)刀#include int gcd(int p,int q){ int r,t=0; if(p<q){ t=p; p=q; q=t;}r=p%

2013-07-14 21:00:02 328

原创 hdu 2138 How many prime numbers

http://acm.hdu.edu.cn/showproblem.php?pid=2138#include #include int isprime(int m){ for(int i=2;i<=sqrt(m);i++) if(m%i==0) return 0; return 1;}int main(){ int T,a; while(scanf

2013-07-14 19:50:24 347

原创 hdu 1108 最小公倍数

http://acm.hdu.edu.cn/showproblem.php?pid=1108import java.util.Scanner;public class Hd{ public static void main(String args[]) { int m,n,a,b; Scanner reader=new Scanner(System.in);

2013-07-13 23:39:32 398

转载 01背包问题 动态规划

动态规划是用空间换时间的一种方法的抽象。其关键是发现子问题和记录其结果。然后利用这些结果减轻运算量。比如01背包问题。/* 一个旅行者有一个最多能用M公斤的背包,现在有N件物品,它们的重量分别是W1,W2,...,Wn,它们的价值分别为P1,P2,...,Pn.若每种物品只有一件求旅行者能获得最大总价值。输入格式:M,NW1,P1W2,P2......

2013-06-24 19:25:22 523

原创 hdu 1157 Who's in the Middle

http://acm.hdu.edu.cn/showproblem.php?pid=1157Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6012 Accepted Submission(s): 3003Problem

2013-03-19 22:16:13 337

转载 sort函数

头文件:  #include             using namespace std;1 默认的sort函数是按升序排列   sort(a,a+n);//两个参数分别为待排数组的首地址和尾地址2 可以自己写一个cmp函数,按特定意图排序int cmp(const int &a,const int &b){  if(a>b)     return 1; els

2013-03-19 21:49:45 528

原创 HDU 1197 Specialized Four-Digit Numbers

http://acm.hdu.edu.cn/showproblem.php?pid=1197#includeint change(int n,int base){ int a=0; while(n) { a+=n%base; n=n/base; } return a;}int main(){ int sum10,sum12,sum16,i; for(i=2992

2013-02-05 11:34:06 211

原创 hdu 1219 AC Me

http://acm.hdu.edu.cn/showproblem.php?pid=1219#include#includechar s[100001];int a[26];int main(){ int i;while(gets(s)){ memset(a,0,sizeof(a));for(i=0;i{if(s[i]>='a'&&s[i]a

2013-02-04 15:20:02 172

原创 hdu 2399 GPA

HDU 2399 GPAhttp://acm.hdu.edu.cn/showproblem.php?pid=2399#include#includeint main(){char s[1000];while(gets(s)){ double j=0.00;int sum=0,tag=1;for(int i=0;i{if(s[i]==' ')

2013-02-02 10:45:47 182

2048游戏源码

2048游戏Android源代码 可运行

2014-07-12

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除