
2018暑假
s_h_w_s_n_g
这个作者很懒,什么都没留下…
展开
-
Find Integer
Problem Descriptionpeople in USSS love math very much, and there is a famous math problem .give you two integers n ,a ,you are required to find 2 integers b ,c such that an +bn=cn . Inputo...原创 2018-09-02 15:55:25 · 188 阅读 · 0 评论 -
Longest Increasing Subsequence
Description 给出一组长度为nnn的序列,a1,a2,a3,a4...ana_1,a_2,a_3,a_4...a_na1,a2,a3,a4...an, 求出这个序列长度为kkk的严格递增子序列的个数 Input 第一行输入TTT组数据 T(0≤T≤10)T (0\leq T\leq 10)T(0≤T≤10)第二行输入序列大小n(1≤n≤100)n(1\...原创 2018-08-05 23:40:49 · 126 阅读 · 0 评论 -
B - Stone Game
这题看懂之后还是相当简单的:三个状态求sg:(s,s)必败态s一定时求能到(s,s)的必胜态(s,c);根据题意可知当c+c*c>=s时都为必胜态,现在考虑临界情况t+t*t==s,此时t刚好为必胜态,若t再减小一则变为必败态因为(s,t)只能到必胜态;当t在增大时状态无法直接确定;故分以下三种状态:1.c>t:必胜sg呈链状sg[s-c]=mex(sg[y]|0...原创 2018-08-01 10:10:05 · 299 阅读 · 0 评论 -
牛客-练习赛23-D
题目描述托米没有完成上一个任务,准备施展黑魔法推倒 1317 黑魔法咒语被描述为一个 长为 n 的,仅包含小写英文字母 'a'...'i' 的字符串,在托米所在的星球,魔法造成的每次有效伤害都是来自他的一个子序列,对于每一个 'a'... 'i' 的排列(共 9! 种),若作为咒语的子序列出现, 就会造成 1 的伤害 而咒语的总伤害为所有 'a'... 'i' 的排列造成的伤害...原创 2018-07-28 09:21:57 · 97 阅读 · 0 评论 -
欧拉---总结
#define maxn 100005;//欧拉函数打表计算出phi(1),phi(2)....phi(n); int phi[maxn];void phi_table(int n){ for(int i=2;i<=n;i++)phi[i]=0; phi[1]=1; for(int i=2;i<=n;i++) { if(!phi[i]) for(in...原创 2018-07-31 20:10:10 · 153 阅读 · 0 评论 -
S-Nim
DescriptionArthur and his sister Caroll have been playing a game called Nim for some time now. Nim is played as follows: The starting position has a number of heaps, all containing some, not neces...原创 2018-07-31 17:30:29 · 250 阅读 · 0 评论 -
灯塔-牛客
题目描述Z市是一座港口城市,来来往往的船只依靠灯塔指引方向。在海平面上,存在n个灯塔。每个灯塔可以照亮以它的中心点为中心的90°范围。特別地, 由于特殊限制,每个灯塔照亮范围的角的两条边必须要么与坐标轴平行要么与坐标轴成45°。 由于经费限制,Z市的灯塔只能被点亮一座。你需要求出在这种情况下,是否存在一座灯塔能够照亮Z市的所有灯塔。输入描述:第一行一个整数T,表示数据组数。对于每...原创 2018-08-04 10:29:40 · 264 阅读 · 0 评论 -
A Chess Game
Submit StatusDescriptionLet's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The positions are constituted as ...原创 2018-08-02 11:51:51 · 503 阅读 · 0 评论 -
快速幂及矩阵快速幂模板
快速幂是基于减少运算次数来提高运算速度的方法普通快速幂//求x的n次幂 int QuickPow(int x,int N){ int res=x; int ans=1; while(N) { if(N&1) { ans=ans*res; } res=res*res; N=N>>1; } return ans;}矩阵快速幂...原创 2018-08-14 18:00:21 · 277 阅读 · 0 评论 -
最小换乘-nyoj
Version:1.0 StartHTML:000000210 EndHTML:000006199 StartFragment:000003175 EndFragment:000006155 StartSelection:000003266 EndSelection:000006137 SourceURL:http://47.94.248.118/problem.php?cid=1004&...原创 2018-09-02 14:22:16 · 180 阅读 · 0 评论 -
poj-1003 坠落的蚂蚁
描述一根长度为1米的木棒上有若干只蚂蚁在爬动。它们的速度为每秒一厘米或静止不动,方向只有两种,向左或者向右。如果两只蚂蚁碰头,则它们立即交换速度并继续爬动。三只蚂蚁碰头,则两边的蚂蚁交换速度,中间的蚂蚁仍然静止。如果它们爬到了木棒的边缘(0或100厘米处)则会从木棒上坠落下去。在某一时刻蚂蚁的位置各不相同且均在整数厘米处(即1,2,3,…99厘米),有且只有一只蚂蚁A速度为0,其他蚂蚁均在向左...原创 2018-09-01 10:53:21 · 537 阅读 · 0 评论 -
袜子
silchen有N只袜子(不区分左右脚),第i只袜子的颜色是Ci,在接下去的M天,他每天都要穿2只袜子出门。我们知道接下去的第i天,他将会穿编号为ai,bi的2只袜子。 众所周知,每天穿的2只袜子颜色要是一样的。现在silchen有机会更改任意袜子的颜色,他希望可以更改最少的袜子颜色,使得每一天穿的2只袜子颜色相同。输入第一行输入一个T,代表数据组数,T小于等于5每组数据第一行...原创 2018-08-28 21:54:09 · 493 阅读 · 0 评论 -
Rikka with Nash Equilibrium-hdu
Problem DescriptionNash Equilibrium is an important concept in game theory.Rikka and Yuta are playing a simple matrix game. At the beginning of the game, Rikka shows an n×m integer matrix A . And t...原创 2018-08-21 10:44:24 · 285 阅读 · 0 评论 -
list-用法
https://blog.youkuaiyun.com/lskyne/article/details/10418823/原创 2018-08-13 10:14:22 · 134 阅读 · 0 评论 -
度度熊学队列-2018百度之星初赛
度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣。初始时有 NNN 个空的双端队列(编号为 111 到 NNN ),你要支持度度熊的 QQQ 次操作。①111 uuu www valvalval 在编号为 uuu 的队列里加入一个权值为 valvalval 的元素。(w=0w=0w=0 表示加在最前面,w=1w=1w=1 表示加在最后面)。②222 uuu www 询问编号为 ...原创 2018-08-13 10:11:03 · 185 阅读 · 0 评论 -
Flow Problem
DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph. InputThe first line of input con...原创 2018-08-08 10:09:50 · 400 阅读 · 0 评论 -
Beautiful Now
Problem DescriptionAnton has a positive integer n , however, it quite looks like a mess, so he wants to make it beautiful after k swaps of digits.Let the decimal representation of n as (x1x2⋯xm)10 ...原创 2018-08-07 15:45:45 · 304 阅读 · 0 评论 -
牛客多校赛3-c题
3. Eddy likes to play cards game since there are always lots of randomness in the game. For most of the cards game, the very first step in the game is shuffling the cards. And, mostly the randomnes...原创 2018-07-27 10:05:38 · 206 阅读 · 0 评论 -
牛客多校赛四
4. Chiaki has an n x n matrix. She would like to fill each entry by -1, 0 or 1 such that r1,r2,...,rn,c1,c2, ..., cn are distinct values, where ri be the sum of the i-th row and c i be the s...原创 2018-07-30 10:33:08 · 192 阅读 · 0 评论 -
Colored Sticks
字典树+并查集+欧拉回路#include<cstdio>#include<string.h>const int maxv=30;int color=0;int degree[500010]={0};int f[500010];//*****************字典树部分**********////建立字典树节点typedef struct Node{ struct No...原创 2018-07-16 00:00:32 · 132 阅读 · 0 评论 -
2^x mod n = 1
DescriptionGive a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1. InputOne positive integer on each line, the value of n. OutputIf the minimum x exists, print a line w...原创 2018-07-17 19:25:03 · 182 阅读 · 0 评论 -
A - 找新朋友
Description新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数,否则都是新朋友,现在会长想知道究竟有几个新朋友?请你编程序帮会长计算出来。 Input第一行是测试数据的组数CN(Case number,1<CN<10000),接着有CN行正整数...原创 2018-07-17 19:09:58 · 290 阅读 · 0 评论 -
排序2-4
D - Find them, Catch themTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionThe police office in Tadu City decides to say ends to the chaos, as lau...原创 2018-07-10 23:41:00 · 257 阅读 · 1 评论 -
排序2-1
A - Who's in the MiddleTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionFJ is surveying his herd to find the most average cow. He wants to know h...原创 2018-07-10 23:28:09 · 93 阅读 · 0 评论 -
字符串1-3
C - All in AllTime Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64uSubmit Status Practice POJ 1936DescriptionYou have devised a new encryption technique which encodes a mess...原创 2018-07-10 00:07:34 · 135 阅读 · 0 评论 -
字符串1-2
B - Blue JeansTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit Status Practice POJ 3080DescriptionThe Genographic Project is a research partnership between IBM an...原创 2018-07-10 00:05:30 · 172 阅读 · 0 评论 -
小兔的棋盘
Description小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(0,0)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很长时间都没想出来,现在想请你帮助小兔解决这个问题,对于你来说应该不难吧! In...原创 2018-07-17 19:27:42 · 118 阅读 · 0 评论 -
Scoop water
卡特兰数依次把n个数压入栈,最后栈空,求n个数的出栈方式数目;设f(n)表示n个数的出栈方式数;对最后一个数进行分类,设最后一个出栈数为k,则k前面的所有数在k入栈前全部出栈即k-1个数的出栈方式;压入k后还有n-k个数出栈方式数为f(n-k),比k大和比k小相互独立f(n)=(k:1-n)f(k-1)(n-k)卡特兰数前几项:1, 1, 2, 5, 14, 42, 132, 4...原创 2018-07-18 15:30:29 · 150 阅读 · 0 评论 -
n皇后问题
Problem Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input 共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示...原创 2018-07-21 10:39:27 · 116 阅读 · 0 评论 -
Knight's Journey
DescriptionBackground The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two squa...原创 2018-07-13 23:39:16 · 113 阅读 · 0 评论 -
Time Zone
Problem DescriptionChiaki often participates in international competitive programming contests. The time zone becomes a big problem.Given a time in Beijing time (UTC +8), Chiaki would like to know ...原创 2018-07-25 09:53:18 · 117 阅读 · 0 评论 -
区间 (interval)-牛客
题目描述 Apojacsleam喜欢数组。 他现在有一个n个元素的数组a,而他要对a[L]-a[R]进行M次操作: 操作一:将a[L]-a[R]内的元素都加上P 操作二:将a[L]-a[R]内的元素都减去P 最后询问a[l]-a[r]内的元素之和? 请认真看题干及输入描述。输入描述:输入共M+3行:第一行两个...原创 2018-07-24 19:57:55 · 200 阅读 · 0 评论 -
阶乘(factorial)
题目描述输入描述:输入数据共一行,一个正整数n,意义如“问题描述”。输出描述:输出一行描述答案:一个正整数k,表示S的末尾有k个0示例1输入复制10输出复制7说明 由十的因子只有2和5;而2得数目要远多于5所以只要找出5即可#include<stdio.h>int main(){ long lo...原创 2018-07-24 19:53:27 · 585 阅读 · 0 评论 -
A B C C - Check the difficulty of problems(概率dp题)
DescriptionOrganizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following two terms: 1. All of t...原创 2018-07-13 00:30:18 · 169 阅读 · 0 评论 -
Aggressive cows
二分搜索: DescriptionFarmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000...原创 2018-07-18 20:55:35 · 388 阅读 · 1 评论 -
Buy the Ticket
Submit Status 当n=m时,是卡特兰数,当n<m时显然为0,当n>m时先将所有人视为一样,只关注其手中money,用dp[i][j]表示i个50,j个100的排队方式数,对最后一个人进行分类最后一个人为50时,则前面有i-1个50,j个100,其排列方式数为dp[i-1][j],最后一个人为100时同理前面人排列方式为dp[i][j-1];所以有递推公式dp[i][j]...原创 2018-07-18 19:45:08 · 218 阅读 · 0 评论 -
字符串专题1-1
DescriptionYou, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words i...原创 2018-07-09 23:59:53 · 162 阅读 · 0 评论