- 博客(25)
- 收藏
- 关注
原创 学习历程-素数打表
#include<stdio.h> #include<string.h> int main() { int a[10000],n,b[10000],t,i,u; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); t=0; for(i=2;i<=n;i++) { if(a[i]...
2017-08-06 16:08:04 138
原创 学习历程-LCM
#include<stdio.h> int fun(int a,int b) { if(b==0) return a; else return fun(b,a%b); } int main() { int a,b,t,a1,b1; while(1) { scanf("%d%d",&a,&b); a1=a;b1=b; while(b1!=0) ...
2017-08-06 15:46:25 255
原创 学习历程-GCD
#include<stdio.h> int fun(int a,int b) { if(b==0) return a; else return fun(b,a%b); } int main() { int a,b,t; while(1) { scanf("%d%d",&a,&b); while(b!=0) { t=b; b=a%b;...
2017-08-06 15:40:54 167
转载 Hard Process
Hard Process CodeForces - 660C You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive el
2017-09-21 22:29:15 313 1
原创 Get the Containers
Get the Containers LightOJ - 1076 A conveyor belt has a number of vessels of different capacities each filled to brim with milk. The milk from conveyor belt is to be filled into 'm' containers. T
2017-09-19 14:02:12 426
原创 序列变换
序列变换 HDU - 5248 给定序列A={A1,A2,...,An}A={A1,A2,...,An}, 要求改变序列A中的某些元素,形成一个严格单调的序列B(严格单调的定义为:BiBi+1,1≤iNBi)。 我们定义从序列A到序列B变换的代价为cost(A,B)=max(|Ai−Bi|)(1≤i≤N)cost(A,B)=max(|Ai−Bi|)(1≤i≤N)。 请求
2017-09-16 22:47:56 971
原创 超级赛亚ACMer
超级赛亚ACMer HDU - 5246 百小度是一个ACMer,也是一个超级赛亚人,每个ACMer都有一个战斗力,包括百小度。 所谓超级赛亚人的定义,是说如果在对抗中刚好接近极限状态,那就会激发斗志,实力提升. 具体来说,就是百小度现在要接受一些ACMer的挑战了,这些ACMer有n个人,第i个人的战斗力是a[i]。 百小度接下来可以自主安排与这n
2017-09-16 01:19:02 305
原创 River Hopscotch
River Hopscotch POJ - 3258 Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a
2017-09-15 23:23:08 178
原创 Monthly Expense
Monthly Expense POJ - 3273 Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of mon
2017-09-15 16:32:39 208
转载 Trailing Zeroes (III)
Trailing Zeroes (III) LightOJ - 1138 You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know
2017-09-07 12:47:15 196
原创 What Is Your Grade?
What Is Your Grade? HDU - 1084 “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? No
2017-09-06 13:28:18 258
原创 稳定排序
稳定排序 HDU - 1872 大家都知道,快速排序是不稳定的排序方法。 如果对于数组中出现的任意a[i],a[j](i<j),其中a[i]==a[j],在进行排序以后a[i]一定出现在a[j]之前,则认为该排序是稳定的。 某高校招生办得到一份成绩列表,上面记录了考生名字和考生成绩。并且对其使用了某排序算法按
2017-09-05 22:19:22 331
转载 Restoring Painting
Restoring Painting CodeForces - 675B Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so h
2017-09-05 20:03:16 293
原创 学习历程-同余定理两大基本应用
1.大整数取模:应用公式可做到边运算边取余。公式入下:例如:1234%10首先整数都可化成如此形式,如1234化成((1*10+2)*10+3)*10+4进行求余(((1*10+2)*10+3)*10+4)%10此时用到两个公式(a+b)%c=(a%c+b%c)%c(a*b)%c=(a%c*b%c)%c计算过程比较麻烦,多次正反运用公式最终能得到1234%10=(((1%10*10+2)%10*1...
2017-09-05 18:12:04 1645 1
原创 Large Division(大整数取模)
Large Division LightOJ - 1214 Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exis
2017-09-05 16:43:20 266
原创 Subsequence
Subsequence POJ - 3061 A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to fi
2017-09-04 11:02:09 162
原创 (思维)Wet Shark and Bishops
Wet Shark and Bishops CodeForces - 621B Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to b
2017-08-26 22:56:43 164
转载 字典树模板(详细代码注释)
//核心思想:将字母化成数字表示,每一个字母对应结构体指针数组的一个元素, //定义移动指针 p 随着更新不断变化 //初始 p 指向的结构体的结构体指针数组元素无指向,若出现元素对应字母,则使该元素指向下一个结构体 // p 同时也移动到该结构体 #include #include #define idx(x) (x-'a') struct Node { int v; //当前节点
2017-08-22 16:22:52 312
转载 C - Asteroids POJ - 3041
匈牙利算法 本文采自:http://blog.csdn.net/lyy289065406/article/details/6646007 题目描述:你的飞船有个强大的武器可以打小行星,一次可以攻击一行或者一列,求最少的攻击次数。 题目分析:问题可以转化为,选取最少的点,使得这些点与所有的边相邻。把方阵看做一个二分图,v1作为行顶点集,v2作为列顶点集,那x,y可以看做点,图中的点
2017-08-20 18:03:33 144
原创 最短路(Dijkstra算法代码详细注释)
//算法目的:求出每个点到初始点的最小距离。 #include #include #define INF 0x3f3f3f int map[105][105],vis[105],dis[105],n; void Dijkstra(int x) { int min,i,j; memset(vis,0,sizeof(vis)); //vis数组表示某个点是否被访问过,访问过为1,未访问
2017-08-20 14:59:45 788
原创 I Hate It (线段树)
I Hate It Time Limit : 9000/3000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 6 Accepted Submission(s) : 2 Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从
2017-08-17 18:04:10 129
转载 Period (next与循环串)
For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2
2017-08-16 11:40:55 233
转载 Cake HDU - 1722
一次生日Party可能有p人或者q人参加,现准备有一个大蛋糕.问最少要将蛋糕切成多少块(每块大小不一定相等),才能使p人或者q人出席的任何一种情况,都能平均将蛋糕分食. Input每行有两个数p和q. Output输出最少要将蛋糕切成多少块. Sample Input 2 3 Sample Output 4 Hint 将蛋糕切成
2017-08-12 17:33:57 192
转载 动态规划
作者:Hawstein 出处:http://hawstein.com/posts/dp-novice-to-advanced.html 声明:本文采用以下协议进行授权: 自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 ,转载请注明作者及出处。 前言 本文翻译自TopCoder上的一篇文章: Dynamic Programmin
2017-08-07 16:46:53 222
转载 Tempter of the Bone
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone
2017-08-01 09:15:21 252
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人