A题:给定A,N,P,计算A的N!次幂对P取模的结果. 数据范围: T次测试,1 ≤ T ≤ 100 1<=A,N,P<=105 快速幂一下就好了.O(nlogn). AC代码: #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;++i) using namespace std; const int MAXN=1e5+1e4; long long mo[MAXN]; int TT; long long a,…
Problem A. Kicksort 题意抽象一下为: 对于一个每次都从数列正中间取划分数的快速排序,给定一个1-n的排列,问快排的复杂度对于这个排列是否会退化为最坏复杂度. 数据范围: 测试组数1 ≤ T ≤ 100. 2 ≤ N ≤ 10000. 思路: 如连连看一般在一列数中反复消去正中间一个,判断其是否一直是目前数列的最小元素或最大元素. 模拟即可,维护一个当前数列最小值,当前数列最大值,消去边界l和r.(注意到每次消去的元素在原数列中必然组成一个连续区间) 每次判断消去边界应该…
思路: 对于small数据,由于求和及奇数数量两个限制条件均满足区间单调性,可以直接使用尺取法(滑动窗口法)求解. 对于large数据,奇数数量依然是满足区间单调性的.首先使用尺取法,找到所有满足奇数限制条件的区间,然后对于每个区间分别计算不超过D的最大连续子段和.具体来说,可将区间的所有前缀和放到一个multiset中,二分查找即可. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; const…
[Problem Description] Problem On the game show The Last Word, the host begins a round by showing the contestant a string S of uppercase English letters. The contestant has a whiteboard which is initially blank. The host will then present the contesta…
这是现场完整做出来的唯一一道题Orz..而且还调了很久的bug.还是太弱了. Problem When you travel, you like to spend time sightseeing in as many cities as possible, but sometimes you might not be able to because you need to catch the bus to the next city. To maximize your travel enjoy…
https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ff08/0000000000386d5c (kick start上网方式需百度) (第一题ac,第二题ac,第三题,小数据集能ac,第四题,小数据集能ac) 第一题: 大致意思就是要找峰值点(第一,必须严格大于前面所有值,第二,要么是结尾值,要么必须满足比后一位严格大),基础题,略 Problem Isyana is given the number of…
题目链接 题意: 思路: 直接拿别人的图,自己写太麻烦了~ 然后就可以用矩阵快速幂套模板求递推式啦~ 另外: 这题想不到或者不会矩阵快速幂,根本没法做,还是2013年长沙邀请赛水题,也是2008年Google Codejam Round 1A的C题. #include <bits/stdc++.h> typedef long long ll; const int N = 5; int a, b, n, mod; /* *矩阵快速幂处理线性递推关系f(n)=a1f(n-1)+a2f(n-2)+.…
Problem B. Vote A and B are the only two candidates competing in a certain election. We know from polls that exactly N voters support A, and exactly M voters support B. We also know that N is greater than M, so A will win. Voters will show up at the…
Practice Round Problem A GBus count (9pt/15pt) (2019年1月14日,kickstart群每日一题) 题意:有一条笔直的大路,上面有城市编号从 1 开始从左到右一次排列.上面有 N 个 GBuses, 每一个 bus[i] 连接 A[i] 到 B[i] 两个地点(包含这两个地方).我们想要求 P 个城市,每个城市经过的公交车数量. 输入输出 和 数据规模 如下: There exist some cities that are built alo…
Google Code Jam Qualification Round Africa 2010 的第一题,很简单. Problem You receive a credit C at a local store and would like to buy two items. You first walk through the store and create a list L of all available items. From this list you would like to b…
Codeforces Round #486 (Div. 3) A. Diverse Team 题目连接: http://codeforces.com/contest/988/problem/A Description There are n students in a school class, the rating of the i-th student on Codehorses is ai. You have to form a team consisting of k students…