LeeBlog

导航

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 19 下一页

2011年4月7日 #

HDU 1196 lowest bit

摘要: 这题是树状数组的一入门题,lowest bit 就是将相应的十进制转换成二进制,在这个二进制数种从右往左数第一个不为0的位置的权值,有一种简单的做法#include<stdio.h>int main( ){ int n; while( scanf( "%d",&n ) ,n ) printf( "%d\n",n&( -n ) );}比较常规的做法#include<stdio.h>int main( ){ int n,x,y; while( scanf( "%d",&n ) ,n ) { 阅读全文

posted @ 2011-04-07 13:25 LeeBlog 阅读(231) 评论(0) 推荐(0) 编辑

2011年4月5日 #

lucky number 被恶心到的一题目

摘要: Problem F:Lucky numbersTime Limit:1000MS Memory Limit:65536KTotal Submit:108 Accepted:14 Description Digits 6 and 8 are lucky, while all others are unlucky. An integer is lucky if it contains only lucky digits in decimal notation. We would like to know the K-th lucky positive integer. Input The firs 阅读全文

posted @ 2011-04-05 22:42 LeeBlog 阅读(944) 评论(0) 推荐(0) 编辑

输入密码

摘要: int inputps(char p1[]){ int i=0; char ch; while((ch=getch())&&ch!=13) { if(ch==27) return 0; if( ch==8 && i !=0 ) { printf( "\b \b" ); p1[--i] = 0; } else if(ch==8&&i==0) co... 阅读全文

posted @ 2011-04-05 17:39 LeeBlog 阅读(439) 评论(0) 推荐(0) 编辑

HDU 2689 sort it

摘要: 此题就是求冒泡的次数,用冒泡做时间比较长,用树状数组做比较快#include<stdio.h>int num[1024],n;int main( ){ while( scanf( "%d",&n ) != EOF ) { for( int i = 0; i < n; ++i ) scanf( "%d",&num[i] ); int count = 0; for( int i = 0,f = 0; i < n - 1; ++i ) { f = 0; for( int j = 0; j + 1< n - i; + 阅读全文

posted @ 2011-04-05 14:23 LeeBlog 阅读(196) 评论(0) 推荐(0) 编辑

hdu 1166 敌兵布阵 树状数组 模板题

摘要: 这题是树状数组入门的一模板题,非常基础,被小白成为"赤裸裸"的入门题,哈哈,一个plus,一个sum全部搞定#include<stdio.h>#include<string.h>#define lowbit( x ) ( x )&( -x )int tree[50024],num,n;void plus( int num,int x ){ while( x <= n ) { tree[x] += num; x += lowbit( x ); } }int sum( int x ){ int sum = 0; while( x ) { s 阅读全文

posted @ 2011-04-05 13:48 LeeBlog 阅读(411) 评论(0) 推荐(0) 编辑

2011年3月31日 #

HDU 1021 Fibonacci Again

摘要: 这题一开始没看懂题,英文啊 ,不懂,后来一百度才知道是判断第n项fib能否被3整除;这题如果打表就会挂掉去,仔细分析fib各项可知每四项中有一项可以被3整除,而且是从0开始的第二项所以代码如下很水啊 !!!!!!!!!!!!!!!!!!!#include<stdio.h>int main( ){ int n; while( scanf( "%d",&n ) != EOF ) if( ( n + 2 ) % 4 == 0 ) puts( "yes" ); else puts( "no" ); return 0;} 阅读全文

posted @ 2011-03-31 21:21 LeeBlog 阅读(234) 评论(0) 推荐(0) 编辑

2011年3月29日 #

HDU 1047 Integer Inquiry

摘要: JAVA水过import java.io.*;import java.util.*;import java.math.*;public class aa{ public static void main( String[]args ) { Scanner cin=new Scanner(System.in); int t; cin.hasNextInt(); t = cin.nextInt(); for( int i = 1; i <= t; ++i ) { BigInteger a,b,c; c = BigInteger.valueOf(0); b = c; while( cin.ha 阅读全文

posted @ 2011-03-29 20:15 LeeBlog 阅读(209) 评论(0) 推荐(0) 编辑

HDU 1042 N!

摘要: JAVAimport java.io.*;import java.util.*;import java.math.BigInteger;import java.math.BigDecimal;;public class aa{ public static void main( String args[] ) { int a; Scanner in = new Scanner ( System.in ); //int t = in.nextInt(); while( in.hasNext() ) { a = in.nextInt(); BigInteger res = BigInteger.ON 阅读全文

posted @ 2011-03-29 17:26 LeeBlog 阅读(247) 评论(0) 推荐(1) 编辑

HDU 1002 A + B Problem II 大数相加

摘要: java 水过import java.io.*;import java.util.*;import java.math.BigInteger;public class aa{ public static void main( String args[] ) { BigInteger a,b; Scanner in = new Scanner ( System.in ); int t = in.nextInt(); for( int i = 1; i <= t; ++i ) { in.hasNext(); a = in.nextBigInteger();b = in.nextBigInte 阅读全文

posted @ 2011-03-29 15:51 LeeBlog 阅读(889) 评论(1) 推荐(0) 编辑

2011年3月27日 #

HDU 1406 完数

摘要: 水题#include<stdio.h>int p[10001];void chart( ){ p[0] = 0; for( int i = 1; i <= 10010; ++i ) { int f = 1,sum = 0; for( int k = 1; k <= i / 2; ++k ) { if( i % k == 0 ) sum += k; if( sum > i ) break; } if( i == sum ) p[i] = p[i - 1] + 1; else p[i] = p[i - 1]; } }int main( ){ chart( ); int 阅读全文

posted @ 2011-03-27 01:16 LeeBlog 阅读(223) 评论(0) 推荐(0) 编辑

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 19 下一页