P2862 [USACO06JAN]把牛Corral the Cows 题目描述 Farmer John wishes to build a corral for his cows. Being finicky beasts, they demand that the corral be square and that the corral contain at least C (1 <= C <= 500) clover fields for afternoon treats. The co…
P2862 [USACO06JAN]把牛Corral the Cows 题目描述 Farmer John wishes to build a corral for his cows. Being finicky beasts, they demand that the corral be square and that the corral contain at least C (1 <= C <= 500) clover fields for afternoon treats. The co…
P2862 [USACO06JAN]把牛Corral the Cows 题目描述 Farmer John wishes to build a corral for his cows. Being finicky beasts, they demand that the corral be square and that the corral contain at least C (1 <= C <= 500) clover fields for afternoon treats. The co…
P2862 [USACO06JAN]把牛Corral the Cows 题目描述 Farmer John wishes to build a corral for his cows. Being finicky beasts, they demand that the corral be square and that the corral contain at least C (1 <= C <= 500) clover fields for afternoon treats. The co…
P1291 [SHOI2002]百事世界杯之旅 题目描述 "--在2002年6月之前购买的百事任何饮料的瓶盖上都会有一个百事球星的名字.只要凑齐所有百事球星的名字,就可参加百事世界杯之旅的抽奖活动,获得球星背包,随声听,更克赴日韩观看世界杯.还不赶快行动!" 你关上电视,心想:假设有n个不同的球星名字,每个名字出现的概率相同,平均需要买几瓶饮料才能凑齐所有的名字呢? 输入输出格式 输入格式: 整数\(n\)(2≤n≤33),表示不同球星名字的个数. 输出格式: 输出凑齐所有的名字平均需…
题目描述 约翰打算建一个围栏来圈养他的奶牛.作为最挑剔的兽类,奶牛们要求这个围栏必须是正方 形的,而且围栏里至少要有C< 500)个草场,来供应她们的午餐. 约翰的土地上共有C<=N<=500)个草场,每个草场在一块1x1的方格内,而且这个方格的 坐标不会超过10000.有时候,会有多个草场在同一个方格内,那他们的坐标就会相同. 告诉约翰,最小的围栏的边长是多少? 输入输出格式 输入格式: Line 1: Two space-separated integers: C and N Lin…
传送门 可以二分边长 然后另开两个数组,把x从小到大排序,把y从小到大排序 枚举x,可以得到正方形的长 枚举y,看看从这个y开始,往上能够到达多少个点,可以用类似队列来搞 其实发现算法的本质之后,x可以不用从小到大排序 #include <cstdio> #include <iostream> #include <algorithm> #define N 1001 #define max(x, y) ((x) > (y) ? (x) : (y)) int c, n…
P4714 「数学」约数个数和 题意(假):每个数向自己的约数连边,给出\(n,k(\le 10^{18})\),询问\(n\)的约数形成的图中以\(n\)为起点长为\(k\)的链有多少条(注意每个点都有自环) 这样想是做不出来题的. 正常的题意是:询问\(n\)的约数的约数的....(共\(k\)次复读后)约数个数和. 考虑\(f_k(n)\)表示答案. 显然有\(f_{k}(n)=\sum_{d|n}f_{k-1}(d)\) 注意到用数论卷积的形式可以表示为 \[ \mathtt f_k=\…
P4345 [SHOI2015]超能粒子炮·改 题意 求\(\sum_{i=0}^k\binom{n}{i}\),\(T\)组数据 范围 \(T\le 10^5,n,j\le 10^{18}\) 设\(f(n,k)=\sum_{i=0}^k\binom{n}{i}\) \[ \begin{aligned} &f(n,k)\\ =&\sum_{i=0}^k\binom{n/p}{i/p}\binom{n\%p}{i\%p}\\ =&\sum_{j=0}^{k/p-1}\binom{n…
P1691 有重复元素的排列问题 题目描述 设\(R={r_1,r_2,--,r_n}\)是要进行排列的\(n\)个元素.其中元素\(r_1,r_2,--,r_n\)可能相同.使设计一个算法,列出\(R\)的所有不同排列. 给定\(n\)以及待排列的\(n\)个元素.计算出这\(n\)个元素的所有不同排列. 输入输出格式 输入格式: 第1行:元素个数\(n(1<=n<500)\) 第2行:一行字符串,待排列的\(n\)个元素 输出格式: 计算出的\(n\)个元素的所有不同排列,最后一行是排列总…