自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

君卿的博客

逆风的方向,更适合飞翔,我不怕千万人阻挡,只怕自己投降。

  • 博客(46)
  • 收藏
  • 关注

原创 洛谷P1003_铺地毯

题目提供者CCF_NOI 评测方式云端评测 标签NOIp提高组2011 难度普及- 时空限制1000ms / 128MB题目描述为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯。一共有nn张地毯,编号从11到nn。现在将这些地毯按照编号从小到大的顺序平行于坐标轴先后铺设,后铺的地毯覆盖在前面已经铺好的地毯之...

2019-03-27 09:53:21 198

原创 HDU 1711 Number Sequence (kmp匹配基础模板)

Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K ...

2018-08-18 11:34:54 226

原创 P1736 创意吃鱼法(dp+前缀和优化)

题目描述回到家中的猫猫把三桶鱼全部转移到了她那长方形大池子中,然后开始思考:到底要以何种方法吃鱼呢(猫猫就是这么可爱,吃鱼也要想好吃法 ^_*)。她发现,把大池子视为01矩阵(0表示对应位置无鱼,1表示对应位置有鱼)有助于决定吃鱼策略。在代表池子的01矩阵中,有很多的正方形子矩阵,如果某个正方形子矩阵的某条对角线上都有鱼,且此正方形子矩阵的其他地方无鱼,猫猫就可以从这个正方形子矩阵“对角线...

2018-08-11 20:56:25 209

原创 最大子段和(DP 思想)

N个整数组成的序列a11,a22,a33,…,ann, 求该序列如aii+ai+1i+1+…+ajj的连续子段和的最大值。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。Input第1行:整数序列的长度N(2 <= N <= 50000) 第2 - N + 1行:N个整数(-10^9 <= Aii ...

2018-08-09 21:04:49 1156

原创 Tickets (DP,递推求最小值)

Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as...

2018-08-09 20:55:54 338

原创 钱币兑换问题

在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sample Input293412553Sample Output71883113137761第一种思想:他是要求完全背包的分配方案数,和原先学习的完全背包不太一样...

2018-08-07 21:12:35 5975 1

原创 超级楼梯

有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?Input输入数据首先包含一个整数N,表示测试实例的个数,然后是N行数据,每行包含一个整数M(1<=M<=40),表示楼梯的级数。Output对于每个测试实例,请输出不同走法的数量Sample Input223Sample Output12思想:就是...

2018-08-07 20:33:14 123

原创 一只小蜜蜂... (dp,递推)

有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。 其中,蜂房的结构如下所示。  Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0<a<b<50)。 Output对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行。 Sa...

2018-08-07 20:28:30 221

原创 存图方式:链式前向星 模板

链式前向星其实就是模拟指针,自己定义的数组存的“地址”,然后结构体里面有一个变量专门记录下一个数据的“地址”。自己找着别人的代码写一遍,加深记忆。cnt可以是从1开始的。 #include<bits/stdc++.h>using namespace std;#define MAX 5000struct edge{ int v; int e; int nex...

2018-08-04 19:58:52 258

原创 coprime sequence (前缀gcd+后缀gcd)

Do you know what is called ``Coprime Sequence''? That is a sequence consists of nnpositive integers, and the GCD (Greatest Common Divisor) of them is equal to 1. ``Coprime Sequence'' is easy to find ...

2018-08-02 21:06:41 385

原创 vacations 暴力求解

Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was c...

2018-08-02 18:06:59 229

转载 放苹果 (递归,递推)

POJ-1664 放苹果放苹果Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21021   Accepted: 13395 Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。...

2018-08-01 20:57:26 3109

原创 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 ...

2018-08-01 16:17:44 262

原创 Robot Motion

A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The possible instructions are N north (up the ...

2018-07-31 20:53:05 207

原创 Rescue bfs典型模板

Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angel's friends want to...

2018-07-31 15:57:34 297

原创 二分搜索 Trailing Zeroes (III)

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 N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tra...

2018-07-28 18:05:34 120

原创 A - Stages 简单贪心

Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be des...

2018-07-28 15:20:04 213

原创 栈和队列 The kth great number (优先队列)

Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number written by Xiao Ming ...

2018-07-28 10:15:23 126

原创 3的幂求和

求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 <= N <= 10^9)340这个如果直接求,会爆,所以找了个简单的。直接根据等比数列的求和公式再加一个求q-1的逆元,不过貌似2关于1e9+7的逆元可以背下来,反正我就偷个懒~~~还有一种递推的方法有点复杂,以后再补吧~~~ #include...

2018-07-24 16:30:34 972

原创 费马小定理 A/B

要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。Output对应每组数据输出(A/B)%9973。Sample Input2...

2018-07-24 11:02:46 249

原创 poj 2524 宗教 并查集

做并查集时,会出现让你求剩余多少(其他的都连在一个树上了)时是没有连的,或者总共有分成了几组这种类似的题,用单个时的个数N,每并一个,减一个剩余=(N-1)--;组数=N--;两个树并时,是树根并,不是父节点并,自己总搞错!!!#include<iostream>#include<algorithm>using namespace std;int fa[50005];voi...

2018-05-10 19:28:12 116

原创 会场安排 (南阳理工oj简单贪心)

描述学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办。小刘的工作就是安排学校小礼堂的活动,每个时间最多安排一个活动。现在小刘有一些活动计划的时间表,他想尽可能的安排更多的活动,请问他该如何安排。输入第一行是一个整型数m(m<100)表示共有m组测试数据。每组测试数据的第一行是一个整数n(1<n<10000)表示该测试数据共有n个活动。...

2018-05-07 22:36:58 133

原创 链条 简单贪心 (可以和会长时间安排类比)

给出n对数字,每个对数字由两个数a和b构成,其中a<b,现在用一些对拼成最长的链,要使得 b1 < a2, b2 < a3 ... 求最长链的长度。Input有多组测试数据。每组测试数据的第一行有一个数字N(1<=N<=10^5)。接下来有n对数字ai和bi,数据保证保证ai<bi,0<=ai,bi<=10^9。处理到文件结束。Output对于每组测...

2018-05-07 22:32:58 149

原创 6174问题

#include<iostream>#include<algorithm>using namespace std;int b[4]={0};int msort(){// for(int i=1;i<=3;i++)// {//  for(int j=0;j<=3-j;j++) //冒泡好像很费时间,不能用 //  {//   int t;//   if(b[j]&...

2018-05-05 22:43:38 279

原创 hpu 1006 思维

#include<iostream>  using namespace std;  //3个中间坐一个,旁边俩都不能坐了。。。 //思维真的很重要。。。 int main()  {      int n,m;    cin>>n;    while(n--)    {     int s;     cin>>m;     if(m==1)     s=1;   ...

2018-04-22 20:05:32 105

原创 畅通工程 并查集 一

#include<iostream>#include<cstdio> using namespace std;int fa[10010];int find(int x){ return fa[x]==x?x:(fa[x]=find(fa[x]));//路径压缩 ,使搜索过的直接接在树根上}void unite(int x,int y){ int a,b; a=find(x)...

2018-04-18 21:00:23 155

原创 独木舟 贪心

#include<iostream>#include<algorithm>using namespace std;long long a[10010];int main(){ long long n,k=0; long long i,t=0,max; cin>>n>>max; for(i=0;i<n;i++) {  cin>>a[i...

2018-04-12 13:07:34 191

原创 A Famous Music Composer

#include<iostream>#include<cstdio>#include<cstring>#include<stdlib.h>using namespace std;int main(){ //string a,b;注意字符串比较要用strcmp函数,不能直接比较,而且不能用string数据类型  char a[5],b[15]; int...

2018-04-10 22:03:56 643

原创 素数距离问题

描述现在给出你一些数,要求你写出一个程序,输出这些整数相邻最近的素数,并输出其相距长度。如果左右有等距离长度素数,则输出左侧的值及相应距离。如果输入的整数本身就是素数,则输出该素数本身,距离输出0输入第一行给出测试数据组数N(0<N<=10000)接下来的N行每行有一个整数M(0<M<1000000),输出每行输出两个整数 A B.其中A表示离相应测试数据最近的素数,B表示...

2018-04-10 20:48:08 232

原创 埃式筛选素数

//筛选n以内有多少个素数 #include<iostream>#include<string.h>using namespace std;//int prime[1000001];int is_prime[1000001];int assx(int p){ int i,c=0,j;// memset(prime,1,sizeof(int)*1000001);加这个数组可以...

2018-03-27 20:38:57 152

原创 自制 学生管理系统(vector的用法)

#include<iostream>#include<cstdio>#include<stdlib.h>#include<vector>#include<algorithm>using namespace std;class Stu{public:string num;string sex;strin...

2018-03-25 20:02:37 3979 4

原创 美素数

//  小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识。 //  问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“美素数”,如29,本身是素数,而且2+9 = 11也是素数,所以它是美素数。 //  给定一个区间,你能计算出这个区间内有多少个美素数吗? //Input//第一行输入一个正整数T,表示总共有T组数据(T &l...

2018-03-23 08:59:44 294

原创 寻找单身狗 思维

#include&lt;iostream&gt;using namespace std;int a[10000010];int main(){ int s=0,i,n;// int a[10000010];数组太大,不能运行;遇到大的数组,要在main函数外申请储存。  cin&gt;&gt;n; for(i=0;i&lt;n;i++) cin&gt;&gt;a[i]; for(i=0;i&lt;...

2018-03-22 21:34:00 240

原创 QAQ给定一个小公式,即: f[i]=f[i−1]∗x f[i]=f[i−1]∗x ( i&amp;gt;=2 i&amp;gt;=2 )。他想知道 f[n] 的结果。

又是一道应用快速幂的题仔细看下公式,就是要用快速幂,只是多了一个常数而已。#include&lt;iostream&gt;using namespace std;typedef long long ll;const ll mod=1e9+7;ll ksm(ll a,ll n,ll j){ ll s,b; s=a; b=j-1; while(b) {  if(b&amp;1) s=s*n%mod; ...

2018-03-22 21:03:40 990

原创 水题 出现次数最多的字母

//给定一个只有小写字母和数字组成的字符串,问字符串中出现次数最多的小写字母,若有多个符合要求的,则输出字典序最小的。 //字典序://a&lt;b&lt;c&lt;d&lt;...&lt;z//a&lt;b&lt;c&lt;d&lt;...&lt;z//。 //输入//第一行输入一个整数//T//T//,代表有//T//T//组测试数据。//每组数据输入一个字符串//str//str//。 //...

2018-03-22 20:11:20 774

原创 Wolf and Rabbit

m和n不能互素:若互素,就会遍历所有的洞#include&lt;iostream&gt;using namespace std;int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int main(){ int p,q,n; cin&gt;&gt;n; while(n--) { cin&gt;&gt;p&gt;&gt;q; if(gcd(p,q)==1)...

2018-03-19 21:31:49 154 1

原创 快速幂

就是方便计算a的b次方#include&lt;iostream&gt;using namespace std;int main(){ //string name; //name="abcd"; //cout&lt;&lt;name&lt;&lt;endl;  long long a,n; cin&gt;&gt;n; while(n--) {  long long m,b,j;  cin&gt;&g...

2018-03-19 19:51:10 83

原创 不开心的小明 c++

/*这天小明又不开心了, 小明数学考零分, 麻麻竟然打小明屁股, 小明为了证明自己, 决定解决一道题目来证明自己, 题目意思如下: 给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。 输入第一行输入一个整数t,代表有t组测试数据(t &lt;= 50) 每组数据只有一个整数N(1 &lt;= N &lt;= 10^18) 数据很大,请使用long long代替int。 输出输出N^N...

2018-03-17 21:16:23 646

原创 CodeForces - 731A 简单题

这里有一个密码锁,正上方是指针的位置,每次需要旋转这个锁,让某一个字母对准指针才能够进行下一步,怎么可以转动最小步数,让指针得到想要的字符串。比如 a -&gt; c   最少需要拧动锁 2 次.;一开始指针指着 a,输出想要得到某一个字符串最少需要拧多少下? Input给定一个字符串,小写字母Output输出一个整数,代表最少拧动次数.Sample InputzeusSample Output1...

2018-03-15 21:32:12 268

原创 石头剪刀布

#include&lt;iostream&gt;#include&lt;stdlib.h&gt;#include&lt;time.h&gt;#include&lt;cstdio&gt;//#include&lt;conio.h&gt;//#include&lt;graphics.h&gt;这两个头文件是C中的,C++要用,得自己写 #include&lt;windows.h&gt;using na

2018-03-15 21:24:52 292

空空如也

空空如也

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

TA关注的人

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