自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(49)
  • 收藏
  • 关注

转载 Java 中基本类型和字符串之间的转换

【文章内容从慕课网总结】基本类型转换为字符串有三种方法: 1. 使用包装类的 toString() 方法 例: int c = 520; String str = Integer.toString(c); 2. 使用String类的 valueOf() 方法 例:String str = String.valueOf(c); 3. 用一个空字符串加上基本类型,得到的就是基本类型数据对应

2017-03-27 17:34:13 246

转载 Java 中的 StringBuilder 类的常用方法

【文章内容从慕课网总结】int length() 字符串长度StringBuilder append(参数) 在StringBuilder对象末尾追加参数Stringbuilder insert(int i, 参数) 将参数内容插入StringBuilder对象的指定位置(str[i]位置)String toString() 将StringBuilder对象转换为String对象

2017-03-27 17:06:19 469

转载 Java 中 String类的常用方法

【文章内容从慕课网总结】int length() 字符串长度int indexOf(char ch/ String s) 字符串中第一次出现字符ch/字符串s的位置(“JAVA”中A第一次出现的位置是2,不是1)int lastIndexOf(char ch/ String s)  字符串中最后一次出现字符ch/字符串s的位置String substring(int begin, int las

2017-03-27 16:44:43 249

原创 ***POJ 3279 Fliptile【格子翻转】

原题链接思路: 有第i+1行格子的反转来改变第i行中黑格子的颜色。 先将第一行格子的所有反转方式都列出来,共2^n种,使用二进制的方式枚举(详见代码); 将第一行反转后,若第一行中第j个格子仍为黑,则将第二行第j个格子反转(因为第一行已经反转完毕,所以只有第二行第j个格子的反转能改变它的颜色); 第二行全部判断是否反转后,再第三行,方法同上,依此类推。 直到倒数第二行全变成白色后,判断最后

2017-03-20 22:10:18 398

原创 ***POJ 3276【反转】

这里写链接内容思路:转向的先后顺序不影响结果;同一头牛转向两次等同于没有转向。AC代码:#include <iostream>#include <algorithm> #include <cstdio>#include <cstdlib>#include <cstring>int n, dir[5000], f[5000], ans_m, ans_k;int reverse(int k){

2017-03-20 20:52:00 213

原创 POJ 3320 Jessica's Reading Problem

原题链接思路:尺取法。AC代码:#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <set> #include <map>using namespace std;int n, page, ans, p[1000000];int i, cnt, s, e;

2017-03-19 15:42:51 190

原创 POJ 3061 Subsequence【尺取法】

原题链接思路:尺取法,lower_boundAC代码:#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <queue> using namespace std;int t, n, s, sum[1000002], a[1000002], ans;int ma

2017-03-19 14:42:31 203

原创 POJ 2456 Aggressive cows

原题链接思路:二分搜索。判断间隔为mid时是否满足条件,不断缩小ub和lb间距。AC代码:#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <queue> using namespace std;int n, c, ans, ub, lb, dis[1000

2017-03-19 14:07:39 226

原创 ***POJ 3180 Dollar Dayz【大数处理】

原题链接思路: 动态规划。大数处理。高位是dp/mod,低位是dp%mod。AC代码:#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;//思路:参考完全背包问题。//因为数很大,

2017-03-17 20:16:09 196

原创 ***POJ 3280 Cheapest Palindrome

原题链接思路: 动态规划,回文符。 dp[j][k]是从j到k变为回文符所需的最小花费。AC代码:#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;int N,M;char s[

2017-03-17 19:57:53 200

原创 POJ 3616 Milking Time

原文链接原题: Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤ 1,000,000) hours (conveniently labele

2017-03-17 19:40:33 164

原创 POJ 2385 Apple Catching

原题链接思路: 动态规划。 思路:i秒转移j次:dp[i][j] = max(dp[i-1][j],dp[i-1][j-1]) + 第i秒是否接到苹果 dp[i-1][j]: i秒没有转移 dp[i-1][j-1]:i秒转移了 AC代码:#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib

2017-03-17 19:33:56 189

原创 POJ 1258 Agri-Net

原题链接思路:经典最小生成树问题。AC代码:#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;//思路:图论,最小生成树,prim选点法(kruskal选边法也可) int N;in

2017-03-17 19:24:01 160

原创 POJ 2139 Six Degrees of Cowvin Bacon

原题链接思路:floyd,任意两点最短距离。AC代码:#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>#include <vector>#include <queue>using namespace std;//思路:

2017-03-17 19:20:40 149

原创 ***POJ 2010 Moo University - Financial Aid

原题链接提意: N个名额,C头牛申请入学,F是学校最多能提供的补助金总额。 每头牛有一个分数和需要的补助金。 要求N头入学的牛的分数的中间最大,并输出这个分数。如果不能让N头牛入学,则输出-1。思路: 以每一头牛为中点,求出成绩比它高的N/2头牛的最小补助金和 和 比它低的N/2头牛的最小补助金和。AC代码:#include <iostream>#include <cstdio>#inc

2017-03-17 19:01:08 216

原创 POJ 2236 Wireless Network

原题链接思路:并查集。AC代码:#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>#include <vector>#include <queue>using namespace std;//思路:并查集 struct

2017-03-17 18:36:24 142

原创 ***POJ 3614 Sunscreen

原题链接思路:队列。将防晒霜的SPF值从小到大排序。将spfmin符合条件的牛加入队列(若 spfmin < SPF,SPF增大后仍符合条件),该队列以spfmax的值从小到大排序(若spfmax >= SPF,则符合条件;若spfmax <= SPF,则SPF增加后更不可能符合条件,直接将该牛其移除队列)。AC代码:#include <iostream>#include <cstdio>#in

2017-03-17 18:02:13 187

原创 ***POJ 3046 Ant Counting

原题链接思路: 首先弄清楚T,A,S,B的意思。 T是蚂蚁有多少种。 A是蚂蚁有多少个。 每组蚂蚁数在S~B之间。 output有多少组符合条件。 然后用动态规划。 dp[i][j]在第i种蚂蚁前,已经取了j种蚂蚁。 dp[i+1][j+k] = dp[i][j] + dp[i][j+1] + …… + dp[i][j+k] (已经从i种之前选了j~j+k只蚂蚁,要再选取k~0只第

2017-03-17 17:11:15 172

原创 ***POJ 2229 Sumsets

原题链接题目: Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer power of 2. Here are the possible

2017-03-16 23:48:55 154

原创 POJ 1328 Radar Installation

原题链接思路:贪心。第一个卫星的位置在s1和e1之间,若s2<=e1则不需要新卫星,第一个卫星位置更新为s2和e2之间;若s2>e1则需要新卫星,第二个卫星位置在s2和e2之间。以此类推。AC代码:#include <iostream>#include <cstdio> #include <algorithm>#include <cstdlib>#include <cstring>#inc

2017-03-16 23:22:04 157

原创 POJ 2376 Cleaning Shifts

原题链接思路:贪心。AC代码:#include <iostream>#include <cstdio> #include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>#include <utility>using namespace std;typedef pair<int,int> PII;int N

2017-03-15 23:59:28 145

原创 POJ 3050 Hopscotch

原文链接思路:dfs,以每个格子为起点,上下左右搜索,6次截至(step=5,从0开始),到达过的数字用vis记录,避免重复。AC代码:#include <iostream>#include <cstdio> #include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>using namespace st

2017-03-15 23:42:31 145

原创 POJ 3187 Backward Digit Sums

原题链接思路:N最大为10,可以用next_permulation。AC代码:#include <stdio.h>#include <algorithm>using namespace std;//由于next_permutation是按字典序从小到大的全排列,因此得到的第一组符合数据就是结果,不需要再继续排列验证int n;int sum; int arr[10][10];int main

2017-03-15 23:30:49 170

原创 ***POJ 2718 Smallest Difference【next_permination】

原题链接题意:数字排序组成两个数,求最小差值。思路: next_permutation函数的应用,历遍把数组所有的可能排列顺序。 为求最小差值,分割数组时应使两个数的位数差尽可能小(为1),选取中间值mid为第二个数的开头。

2017-03-15 23:13:23 265

原创 POJ 3009 Curling 2.0

原题链接思路:深搜AC代码:#include <iostream>#include <cstdio> #include <algorithm>#include <cstdlib>#include <cstring>#define INF 1000000using namespace std;//dfs深度搜索 typedef pair<int,int> PII;int data[22]

2017-03-13 23:19:51 156

原创 POJ 1979 Red and Black

原题链接思路:经典深搜AC代码:#include <iostream>#include <cstdio> #include <algorithm>#include <cstdlib>#include <cstring>#include <queue>using namespace std;//与POJ_2386水洼题相似 //dfs深度优先搜索 int ans,dis[21][21],

2017-03-13 23:12:06 139

原创 POJ 3169 Layout

原题链接思路: 转化为有负边的求最短路径问题,用Bellman-Ford算法 将每头牛当作一个顶点,互相亲近的牛由小编号指向大编号的边权值为正,互相厌恶的牛由大编号指向小编号的边权值为负 由i+1号牛指向i号牛的边权值为0 求此图中的最短路径 PS:从起点到j点沿箭头方向的路径上的权值和是第一头牛与j牛的最大距离,因此在所有由起点到j点的路径中,必须选取最小的一个,才能保证所有的路径都不

2017-03-02 18:48:41 170

原创 POJ 3723 Conscription【招募士兵】

原题链接思路:把男生女生都当作顶点,把把亲密度的负数当作权值,就是最小生成树问题。AC代码:#include <iostream>#include <cstdio> #include <algorithm>#include <cstdlib>#include <cstring>using namespace std;//《挑战》 P109//把男生女生都当作顶点,把把亲密度的负数当作权

2017-03-02 18:30:36 280

原创 POJ 3255 Roadblocks

次短路径

2017-03-02 18:26:10 157

原创 ***POJ 1182 食物链

思路:并查集。x,x+N,x+2N分别是编号x的动物为A/B/C类的可能性。每给出一句话,将同时成立的可能性加入一个并查集,判断是否矛盾。

2017-02-22 20:38:47 179

原创 POJ 2431 Expedition

原题链接思路:在剩余油量所能到达的距离内且为使用过的加油站中选择加油最多的一个。用到优先队列。

2017-02-22 20:32:01 158

原创 POJ 3176 Cow Bowling

原题链接思路:动态规划。 动态方程:dp[i][j] = dp[i][j] + max(dp[i-1][j-1], dp[i-1][j]) dp[i][j]表示到点(i,j)的最大数字和。AC代码:#include <iostream>

2017-02-22 20:25:16 184

原创 POJ 1742 Coins

原题链接Description People in Silverland use coins.They have coins of value A1,A2,A3…An Silverland dollar.One day Tony opened his money-box and found there were some coins.He decided to buy a very nice wa

2017-02-22 20:17:35 208

原创 ***POJ 3669 Meteor Shower【流星雨】

原文链接 Description Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to fi

2017-02-21 21:43:31 292

原创 POJ 5253 Fence Repair

思路:倒着想,木块已经全部切割,每次选择最小的两块合并,直到合并为一块位置。

2017-02-21 21:15:39 135

原创 POJ 3069 Saruman's Army

原题链接 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the

2017-02-21 20:08:10 165

原创 ***POJ 3617 Best Cow Line【牛排队】

贪心法,字典序最小问题

2017-02-20 22:37:34 162

原创 POJ 2386 Lake Counting

原题链接Description Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contain

2017-02-20 22:05:21 181

原创 POJ 1852 Ants

原题链接Description An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two an

2017-02-20 21:58:55 115

原创 POJ 1064 Cable master

经典二分

2017-02-20 18:14:37 128

空空如也

空空如也

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

TA关注的人

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