C. Seat Arrangements time limit per test1 second memory limit per test256 megabytes Problem Description Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that…
A. Supermarket We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用pre[i][j]表示第i行前j列的和. 然后枚举连续座位的最左上点. (有两种可能向右或向下k个. 则还需要处理出pre2[i][j]表示第j列前i行的和. (都可以O(N^2)求出 然后pre[i][j+k-1]-pre[i][j-1]就是第i行第j列往右k个格子的空(或被占据)的格子数目了. 看看是不是符合要求就好. 往下扩展同理. k==1的时候只要取向右一种就好.所以直接除个2 [代码] #include <bits…
原文链接http://www.cnblogs.com/zhouzhendong/p/8397685.html 2018-02-01 $A$ 题意概括 你要买$m$斤水果,现在有$n$个超市让你选择. 每个超市的水果价格是固定的.第$i$个超市的水果价格用两个整数$a_i和b_i$来表示.含义是$a_i$元可以买$b_i$斤. 问你买$m$斤水果最少花费多少钱. 题解 直接枚举超市,判断最少的花费就可以了. 代码 #include <cstring> #include <cstdio>…
Supermarket 找最便宜的就行 Solution Perfect Number 暴力做 Solution Seat Arrangement 注意当k=1时,横着和竖着是同一种方案 Solution Substring dp[i][j]表示在节点i结束,字母j最多有多少个,按拓扑排序的顺序计算 Solution Congruence Equation Solution A Game With Numbers 跟SG游戏解决思路差不多 Solution…
题目链接: http://codeforces.com/problemset/problem/919/E 题意: 让你求满足 \(na^n\equiv b \pmod p\) 的 \(n\) 的个数. \(2 ≤ p ≤ 10^{6} + 3, 1 ≤ a, b < p, 1 ≤ x ≤ 10^{12}\). 题解: 因为: $n \mod p $的循环节是 \(p\) \(a^{n} \mod p\)的循环节是 \(p-1\).(费马小定理) 所以: \(na^n \mod p​\)的循环节为…
Problem A:题目传送门 题目大意:给你N家店,每家店有不同的价格卖苹果,ai元bi斤,那么这家的苹果就是ai/bi元一斤,你要买M斤,问最少花多少元. 题解:贪心,找最小的ai/bi. #include <cstdio> using namespace std; double minn=2e9,x,y,M; int N; int read() { '); +c-'; return x; } inline double min(double x,double y){return x<…
D. Substring time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's valu…
E. Congruence Equation time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy where a, b, p are all k…
D. Substring time limit per test3 seconds memory limit per test256 megabytes Problem Description You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the mos…