题目链接:http://codeforces.com/contest/820/problem/C 题解:显然a<=b的规律很好找只要 例如a=2,b=5,只要这样排列就行abbbbbbabbbbbbabbbbbb.... 然后a>b的规律是 例如a=5,b=2,只要这样的排列就行abcdeeeabfghhhabcdeeeanfghhh..... 当然满足这些条件的话就可以求出大于r-l>T的结果(T=2*(a+b)) 显然if(a <= b) ans = a + 1; else a…
A Boring Question Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 865    Accepted Submission(s): 534 Problem Description There are an equation.∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=?We define…
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant very much loves sums on intervals. This time he has a pair of integers l and r (l ≤ r…
题目链接:http://codeforces.com/contest/820/problem/D 题意:求.有一种操作 k = 0: shift p1, p2, ... pn, k = 1: shift pn, p1, ... pn - 1, ..., k = n - 1: shift p2, p3, ... pn, p1.  这样的操作,问sum值最小是多少需要操作几次 题解:这题其实只要模拟一下操作就行了复杂度为O(n)具体看一下代码. #include <iostream> #inclu…
题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99-98),三位的有2099-3098(099-098),四位的有3099-13098(3099-3098) 所以关键字长度一样的会连续出现,1989+0代表一位的开始,1989+10代表两位的开始,1989+10+100代表三位的开始, 现在给你一个长度为len的标志,就可以找出该数位的起始位置198…
C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/C Description A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that des…
Codeforces 1091D New Year and the Permutation Concatenation https://codeforces.com/contest/1091/problem/D 题目: Let n be an integer. Consider all permutations on integers 1 to n in lexicographic order, and concatenate them into one big sequence p. For…
题意:给出两个n*m的矩阵,每次操作可以让一个正方形矩阵行列交换.问,在无限次操作下,第一个矩阵能否变成第二个矩阵 分析:先把操作限定在2*2的矩阵中.这样对角线上的元素就可以随意交换.也就是说,如果给相邻的元素随意的交换次数,那么一个长度为n的数列可以得到任何顺序. 然后把操作放大,发现不在一个对角线上的元素无论如何也是无法交换位置的. ac代码: #include<bits/stdc++.h> using namespace std; const int maxn=505; int num…
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The b…
A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description you the conditions of this task. There are 3 pivots: A, B, C. Initially, n disks of different diameter are placed on the pivot A: the smallest dis…
C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) an…
题目链接:hdu_5793_A Boring Question 题意: 自己看吧,说不清楚了. 题解: 打表找规律 #include<cstdio> typedef long long ll; ; ll pow(ll a,ll b) { ll an=; while(b){ )an=(an*a)%mod; b>>=,a=(a*a)%mod; } return an; } int main(){ int t,n,m; scanf("%d",&t); whil…
题目链接: 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点,转移方程肯定是从其他三个点转移. 代码…
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; int main(void) //Codeforce…
题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; ]; int main(void) //Codeforces Round #309 (Div. 2) A. Kyoya a…
Educational Codeforces Round 78 (Rated for Div. 2) 1278B - 6 B. A and B  time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given two integers aa and bb. You can perform a sequence of…
Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... 考虑打表找规律(u1s1 这是一个非常有用的技巧,因为这个 \(10^{13}\) 给的就很灵性,用到类似的技巧的题目还有这个,通过对这些模数的循环节打表找出它们的共同性质,所以以后看到什么特殊的数据或者数据范围特别大但读入量 \(\mathcal O(1)\) 的题(比如 CF838D)可以考虑小数据打…
Mister B and Book ReadingCodeForces - 820A 题意:C,V0,V1,A,L..总共有C页书,第一天以V0速度读,每天加A,但是不能超过V1,并且要从前一天的看到的当前页数的前L页开始读 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int c,v0,v1,a,l,ans; int main(){ scanf("%d%d…
Ball Painting 题目连接: http://codeforces.com/gym/100015/attachments Description There are 2N white balls on a table in two rows, making a nice 2-by-N rectangle. Jon has a big paint bucket full of black paint. (Don't ask why.) He wants to paint all the b…
Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description Sonny uses a very peculiar pattern when it comes to playing rock-paper-scissors. He likes to vary his moves so that his opponent can't beat him with hi…
C. Pie or die Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/C Description Volodya and Vlad play the following game. There are k pies at the cells of n  ×  m board. Each turn Volodya moves one pie to the neighbo…
B. Lunch Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/B Description The swamp looks like a narrow lane with length n covered by floating leaves sized 1, numbered from 1 to n with a fly sitting on the top of ea…
题目链接:http://codeforces.com/problemset/problem/603/A 题意: 给定一个 $01$ 串,我们“交替子序列”为这个串的一个不连续子序列,它满足任意的两个相邻的数字不相等. 现在,我们要对这个 $01$ 串的某一段非空连续子串进行反转操作,即将这一段上的所有 $0$ 变为 $1$,所有 $1$ 变为 $0$. 然后,求问进行了有且仅有一次的反转操作后,求该串的最长交替子序列的长度. 题解: 首先,对于一个 $01$ 串,对其进行压缩操作,即将所有连续的…
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.…
原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-andrew-stankevich-contest-22-asc-22-en.pdf 题意 给你一个无向图,要从1走到n,问你哪些边去掉之后就没法走原本的最短路了. 题解 跑两发最短路,顺着跑一发,倒着跑一发,对于边(u,v),如果w(u,v)+d[u]+rd[v]或者w(u,v)+d[v]+rd[u]…
题目链接:http://codeforces.com/problemset/problem/117/C C. Cycle time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input output standard output A tournament is a directed graph without self-loops in which every pair of ve…
题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> #include <cmath> #include <vector> using namespace std; ; const int INF = 0x3f3…
链接 Codeforces 676E The Last Fight Between Human and AI 题意 给一个多项式,有些系数不确定.人和机器轮流填系数,系数可以是任何数,问是否能使得最后的多项式整除 x-k 思路 整除x-k就等价 x=k时,多项式为0. 系数可以是任何数的话就能得到任何结果,只要人是否是填最后一个就行. 另外分 k=0 和 k<>0两种情况考虑. 代码 #include <iostream> #include <cstdio> #incl…
D. Flowers time limit per test:1.5 seconds memory limit per test:256 megabytes We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flo…
题目链接: https://codeforces.com/contest/1159/problem/D 题意: 构造一个长度为$n$的$01$串,最小特殊连续字串的长度为$k$ 也就是,存在最小的$k$,满足,有一个长度为$k$的连续字串没有出现过两次 数据范围: $1 \leq k \leq n \leq 100\,000$$(k \bmod 2) = (n \bmod 2)$ 分析: 典型的构造题,构造了一下午的错误题意,…