Codeforces 题面传送门 & 洛谷题面传送门 一道名副其实(beautiful)的结论题. 首先看到这道设问方式我们可以很自然地想到套用斐波那契数列的恒等式,注意到这里涉及到 \(F_{a+id}\),因此考虑斐波那契数列组合恒等式 \(F_{m+n+1}=F_mF_{n}+F_{m+1}F_{n+1}\),具体证明戳这里,这里就不再赘述了. 注意到此题还涉及后 \(18\) 位,也就是要将斐波那契数列的各种运算放到模 \(10^{18}\) 意义下进行,因此我们可以考虑找一下斐波那契数…
现场 1 小时 44 分钟过掉此题,祭之 大力分类讨论. 如果 \(|s|=1\),那么显然所有位置都只能填上这个字符,因为你只能这么填. scanf("%d",&n);mmp['+']=0;mmp['-']=1;mmp['*']=2; for(int i=1;i<=n;i++) scanf("%d",&a[i]); char opt[4];scanf("%s",opt+1);int len=strlen(opt+1); i…
A. Little Pony and Expected Maximum Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/453/problem/A Description Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing.…
题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点的方案数. 思路: 打表找规律得到的序列是0,3,6,21,60,183,546,1641,4920,14763,通过肉眼看或者oeis可以得到规律为. dp计数:dp[i][j]表示在第i步时站在位置j的方案数,j的取值为[0,3],分别表示D,A,B,C点,转移方程肯定是从其他三个点转移. 代码…
题目描述 有一天,一个名叫顺旺基的程序员从石头里诞生了.又有一天,他学会了冒泡排序和独 立集.在一个图里,独立集就是一个点集,满足任意两个点之间没有边.于是他就想把这两 个东西结合在一起.众所周知,独立集是需要一个图的.那么顺旺基同学创造了一个算法, 从冒泡排序中产生一个无向图.  这个算法不标准的伪代码如下: void bubblesortgraph(n,a[]) //输入:点数n,1到n的全排列a //输出:一个点数为n的无向图G {// 创建一个有n个点,0条边的无向图G. do{ swa…
Atcoder 题面传送门 & 洛谷题面传送门 猜结论神题. 首先考虑探究题目中 \(f\) 函数的性质,\(f(p,q)_{p_i}=q_i\leftarrow f(p,q)\circ p=q\),其中 \(\circ\) 为两个置换的复合,\(a\circ b\) 为满足 \(p_{i}=a_{b_i}\) 的置换 \(p\),有点类似于函数的复合,u1s1 我一直把它当作乘法运算,因此总没搞清楚,心态爆炸--等式两边同乘 \(p\) 的复合逆 \(p^{-1}\) 可得 \(f(p,q)=…
http://scottsievert.github.io/blog/2015/01/31/the-mysterious-eigenvalue/ The Fibonacci problem is a well known mathematical problem that models population growth and was conceived in the 1200s. Leonardo of Pisa aka Fibonacci decided to use a recursiv…
[codeforces 528]B. Clique Problem 试题描述 The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of…
Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. Input The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two…
http://codeforces.com/contest/325/problem/B B. Stadium and Games time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Daniel is organizing a football tournament. He has come up with the followin…