自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Kazama_Kenji的博客

没做的时候,认为不可能,做到了,就习以为常。

  • 博客(83)
  • 问答 (1)
  • 收藏
  • 关注

原创 测试一下

2018-04-28 15:12:57 220

原创 Problem 63 Powerful digit counts

Powerful digit countsProblem 63The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.How many n-digit positive integers exist

2017-09-23 16:59:06 387

原创 LeetCode 371. Sum of Two Integers

不用 + , - 运算符进行加法运算。int getSum(int a, int b) { if(b==0) return a; int s = a^b; int w = (a&b)<<1; return getSum(s,w);}没想到还能这样,算是见识了。

2017-03-02 22:39:42 352

原创 HDU1856 More is better (加权并查集)

近几天---并查集的日常:外链并查集题意:这道题目的目的是想知道经过一系列的合并操作之后,查询在所有的子树中,秩的最大值是多少,简而言之,就是最大的那颗子树包含了多少个节点。模板:import java.util.Scanner;public class Main { private int[] id; private int[] sz; private int count;

2016-10-20 22:36:44 394

原创 在Ubuntu下安装codeblocks

打开Synaptic Package Manager并搜索codeblocks现在就可以开始使用codeblocks了一个回显的测试程序

2016-10-16 23:19:53 488

原创 算法分析中的函数

算法分析中的常见函数floor向下取整 不大于x的最大整数ceiling向上取整 不小于x的最小整数ln自然对数 log以e为底的对数lg以2为底的对数Hn调和级数 1+1/2+1/3+1/4+...+1/nN!阶乘 1*2*3*4*....*N算法分析中常用的近似函数符号   ' ~ '  :   近似于调和级数求和

2016-09-22 20:27:42 800

原创 poj 3750 小孩报数问题(队列Queue)

不多说,《算法》第4版 习题1.3.37Josephus问题// poj 3750import java.util.Scanner;public class Main { private static class Queue { private Node first; private Node last; private class Node {

2016-09-20 21:04:04 986

原创 在ubuntu 14.04 64bit 上搭建c/c++集成开发环境

本文搭建的c/c++集成开发环境: eclipse-cdt准备工作:1.检查gcc和g++是否安装,gcc一般会随ubuntu系统安装而一并安装,这里要注意一下g++是否安装了。打开终端,输入g++,如果没有安装,会得到提示,按照提示的最后一句sudo apt-get install g++即可把g++安装好,之后再输入g++即如图所示:说明g++安

2016-09-18 21:05:51 5086

原创 ubuntu系统添加jdk的环境变量

1.去Oracle官网把jdk包下过来(我的是jdk8u101)http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html(记得勾选同意协议)2.准备(1)创建安装目录sudo mkdir /usr/jdk(2)安装jdk  1)在压缩包所在目录解压jdk

2016-09-12 21:51:52 723

原创 如何让《算法》(第4版)的BinarySearch跑起来

首先进入书本的网站http://algs4.cs.princeton.edu/home/因为BinarySearch.java是第一章的一个程序,所以进入第一章的网址你首先需要准备一下:1.

2016-09-10 21:55:01 3916 5

原创 斐波那契数列(记忆化剪枝)

import java.math.BigInteger;public class Main { // public static long start=System.currentTimeMillis(); public static int maxn = 1000; public static BigInteger[] fun = new BigInteger[maxn]; pub

2016-08-26 17:26:28 1272

原创 poj 2251 Dungeon Master

Dungeon MasterTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 26983 Accepted: 10579DescriptionYou are trapped in a 3D dungeon and need to find the quick

2016-08-26 10:45:56 384

原创 poj 1013 Counterfeit Dollar

Counterfeit DollarTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 44714 Accepted: 14170DescriptionSally Jones has a dozen Voyageur silver dollars. Howev

2016-08-25 11:37:03 381

原创 poj 2657 Comfort

ComfortTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2500 Accepted: 859DescriptionA game-board consists of N fields placed around a circle. Fields are

2016-08-23 11:21:49 492

原创 poj 1575 Easier Done Than Said?

Easier Done Than Said?Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4792 Accepted: 2670DescriptionPassword security is a tricky thing. Users prefer si

2016-08-21 22:19:33 441

原创 poj 1674 Sorting by Swapping

Sorting by SwappingTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 9698 Accepted: 5191DescriptionGiven a permutation of numbers from 1 to n, we can al

2016-08-20 09:46:58 687

原创 poj 2546 Circular Area

Circular AreaTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5763 Accepted: 2255DescriptionYour task is to write a program, which, given two circles,

2016-08-18 13:30:26 436

原创 poj 2624 4th Point

4th PointTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5066 Accepted: 1765DescriptionGiven are the (x,y) coordinates of the endpoints of two adjacen

2016-08-17 20:32:36 482

原创 c/c++中整型数据的数据范围

根据题目的数据范围选择合适的数据类型存储是第一个要考虑的问题,所以我们应该了解各种基本数据类型的存储范围在c中,为此定义了一系列常量,你只需包括头文件,就可以输出对应数据类型的最大值和最小值了。代码如下:#include#include#includeusing namespace std;int main(){ //有符号int型最大值和最小值 cout<

2016-08-17 11:52:29 1844

原创 poj 1423 Big Number

第一次是在杭电碰到这个题目(1018),当时刚学java的大数,对于阶乘的问题当时都是一股脑的用java去做,而在这里就不行了,或者说没必要用java大数。(用java大数要么打表的时候超内存,要么不打表超时)题意:1法一:对于一个数n,(log10(n)+1)再取整就是数n的位数。例如:log10(1000)=3.000000,log10(1000)+1=4.000000

2016-08-15 14:58:45 613

原创 poj 1269 Intersecting Lines(直线相交判断,求相交交点)

常规而又直接的计算几何判断直线是否相交题目,如果相交,求相交的交点在这里要注意两点:1、scanf()输入double型数据要用%lf2、用一般式(Ax+By+C=0)判断的直线时候记住重合的充要条件是 A2B1-A1B2==0 && A1C2-C1A2==0 && B1C2-C1B2==0(初高中的几何知识全还给老师了,(-_-))我犯错的时候是用A2B1-A1B2==0 &&

2016-08-13 22:20:49 455

原创 c/c++的时间

时间是个很重要的状态量,在这里记录一下自己学习的一些c/c++的有关时间的知识,但是时间问题其实是一个非常复杂的问题,根据不同需要有非常多的写法,现在只说说一般的两种吧:1.程序运行时间#includeprintf("Time used = %.4f\n",(double)clock()/CLOCKS_PER_SEC);return 0;clock()是在time.h头

2016-08-13 11:05:23 397

原创 poj 3197 Continuous Fractions(java大数)

很久没写解题报告了,因为自己太懒了啊,懒得看英文题,懒得思考,懒得模拟,畏于攻坚,and so on...简而言之就是颓废了啊。Continuous FractionsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 982 Accepted: 375

2016-08-11 11:11:52 467

原创 需要认识的c math 函数

abs()int abs(int num);函数返回参数num的绝对值fabs()double fabs(double arg)函数返回参数arg的绝对值acos()double acos(double arg);函数返回参数arg的反余弦值。参数arg应当在-1和1之间可以利用这个函数定义圆周率:const double pi=acos(-

2016-08-09 19:57:20 363

原创 图论总结

Poj 1258 Agri-Net:题目大意:Farmer John要竞选镇长,他的竞选承诺是让镇上的每一个农场都联上网,问题是怎样做到连接所有的农场且所需光纤最短。问题提炼:以最短的路径连接所有节点。根据问题,算法就是——prim算法(生成最小生成树)//Code:#include#include#includeusing namespace std;const in

2016-08-06 14:49:01 481

原创 poj 1330 Nearest Common Ancestors(并查集?!二分查找)

#include#include#include#includeusing namespace std;pair a[10005];int cun[10005];int cun1[10005];bool cmp(pair a,pair b){    return a.second}int main(){    //freopen(

2016-07-27 11:01:02 297

原创 poj 1060 Modular multiplication of polynomials (多项式问题)

因为freopen("in.txt","r",stdin);贡献了一个超时,以后就的最终代码就是把这行注释掉就行了。相比以前的 freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);和最后的 fclose(stdin); fclose(stdout);四行冗余的代码来说,freopen("in.txt","r"

2016-07-26 12:05:40 434

原创 poj 1996 The Highest Profits(数学多项式)

学长指点关键算法+自己模拟=解题。#include#include#includeusing namespace std;int a[105];int b[105];int t[10005];int over[10005];int cun[10005];int m,n;int main(){    int z;    scan

2016-07-25 22:59:37 376

原创 poj 1001 Exponentiation

写题的时候经常在discuss里面看到“java大法好”,的确很好啊,但是用多了会变笨(学长说),对于我们这些刚刚入坑的菜鸟,有时间和精力还是走c/c++模拟之路吧,毕竟入了坑就不能偷懒啊。import java.math.*;import java.util.Scanner;import java.text.DecimalFormat;public class Main {p

2016-07-25 12:50:59 715

原创 hdu 1316 How Many Fibs?

java 大数:import java.math.BigInteger;import java.util.Scanner;public class Main{static int INF=500;    public static void main(String[] args) {        Scanner cin = new Scanner(System.i

2016-06-10 23:32:16 374

原创 poj 1220 进制转换

熟悉了集成开发环境eclipse,快捷键的熟悉,设置代码提示等学习了java的大整数类和Scanner扫描仪,还有java的String类(可以去查查它的API)Java BigInteger(大数,ACM比赛专用):http://www.cnblogs.com/tsw123/p/4378697.html关于java的大整数类这个网址介绍得很好(还有Scanner)Java S

2016-06-10 18:22:22 511

原创 Algs4 BinarySearch.java

/****************************************************************************** *  Compilation:  javac BinarySearch.java *  Execution:    java BinarySearch whitelist.txt  *  Dependencies: In.jav

2016-06-08 00:52:33 2629 4

转载 hdu 2045 不容易系列之(3)—— LELE的RPG难题

Posted by cdsat 2016-02-12 21:19:16 on Problem 2045(1) 对于cds总结的环形数n用m颜料涂种类数:(m-1)^n + (m-1)*(-1)^n可以当作公式来记忆了#include//环形数n用m颜料涂种类数:(m-1)

2016-05-24 17:10:22 354

原创 c语言中的0

在c语言中,有三种0:1.char型,'\0'   ;asc2值:02.int型,0        ;asc2值:03.char型,'0'   ;asc2值:48从asc2码的值可以看出它们之间的不同了,1,2基本一样,3与1,2相差甚远。

2016-05-21 02:17:29 804

转载 lrj 竖式问题

#include #include int main(){    int count=0;    char s[20],buf[99]={0};    scanf("%s",s);    ;    for(int abc=111;abc        for(int de=11;de    {        int x=abc*(de%10),y=a

2016-05-21 01:59:24 359

转载 lrj 蛇形填数

“画布”(数据):二维数组“画笔”(算法):(x,y)的坐标变换算法:先判断再移动和“作画”。判断是否越界,一开始的界是在n-1*n-1之内,之后逐渐减小。#include #include #define maxn 10using namespace std;int a[maxn][maxn];int main(){

2016-05-21 01:33:15 318

转载 深入了解生成随机数的函数rand()

百度知道:C语言 问题:srand((unsigned)time(NULL));我们知道在产生随机数的时候,需要一个叫做种子seed的值作为产生随机数算法的初始值。而C/C++库中的srand就是为这一次的随机数生成设置种子。s代表的就是seed的意思。time_t time(time_t *time);该函数返回自计算机计时的某个时刻起到现在所过去的秒数。一般是返回自

2016-05-20 18:00:10 932

原创 Uva 455

字符串处理题目,基本是模拟,做这道题目换了几次算法,应了学长的那句话:“字符串题目展现技巧性”。最终是模拟+枚举做出来了。换了几次算法,花了大量的时间,所以做字符串题目首先要想好一个比较全面保险的算法(有些字符串题目有着许多难以预见的陷阱),之后才是模拟把代码写出来,反之很容易像这次一样,之前都是瞎折腾(写到后面发现自己的算法有致命漏洞)。也利用这道题目测试了Uva OJ的I/O格式控制。

2016-05-20 12:11:25 523

原创 Uva 1225

终于写出有竞赛风格的代码了!#include #include #include #include using namespace std;char a[40000];int main(){    int n;    cin>>n;    while(n--)    {        int d;        cin>>d;

2016-05-19 20:06:09 363

原创 Uva 1586

一开始把题意理解错了,很尴尬啊 OrzNH2CH2COOH理解为两个NH两个CH和一个COOH了如果给高中化学老师知道了,不知道他是否会因我汗颜啊#include #include #include #include #include using namespace std;float str[129];int main(){ 

2016-05-19 19:14:57 395

空空如也

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

TA关注的人

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