D. Spongebob and Squares Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m colum…
很容易得到n × m的方块数是 然后就是个求和的问题了,枚举两者中小的那个n ≤ m. 然后就是转化成a*m + c = x了.a,m≥0,x ≥ c.最坏是n^3 ≤ x,至于中间会不会爆,测下1e18就好. #include<bits/stdc++.h> using namespace std; typedef long long ull; vector<ull> ns; vector<ull> ms; //#define LOCAL int main() { #i…
D. Spongebob and Squares   Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m col…
题目链接:http://codeforces.com/problemset/problem/599/D 题意:定义F(n,m)为n行m列的矩阵中方阵的个数,比如3行5列的矩阵,3x3的方阵有3个.2x2的方阵有8个.1X1的方阵有15个,所以F(3,5)=3+8+15=26.现在告诉你F(a,b)=x中的x,要你求出所有满足要求的a,b,并按a递增的顺序输出. 思路:找出n行m列的矩阵中方阵数量的表达式即可,有些小细节需要注意... code: #include <iostream> #inc…
据题意: $K=\sum\limits_{i=0}^{n-1}(n-i)*(m-i)$ $K=n^2m-(n+m)\sum{i}+\sum{i^2}$ 展开化简 $m=(6k-n+n^3)/(3n^2+3n)$ 枚举n,验证整除,只做n<=m,其余反过来输出即可 #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstri…
D. Spongebob and Squares time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all…
D. Spongebob and Squares Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/problem/D Description Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of…
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的时候gg了..其实稍微在纸上推一下.就会得到对于n,m的矩形,一共会有-n*n*n+3*n*n*m+n+3*n*m的方格.数量级是n3. 我们可以实际跑一遍.发现对于x1E18的数量级,n不会超过1442550,1E6,可以搞. 需要注意的是,一个是会爆int,所以记得用long long 另一个是…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that t…
http://codeforces.com/problemset/problem/599/D 题意:给出一个数x,问你有多少个n*m的网格中有x个正方形,输出n和m的值. 思路: 易得公式为:$\sum_{i=0}^{n}(n-i)(m-i) $ 化简得:$\left [ n(n+1)-\frac{n(n+1)}{2}\right ]*m+\frac{n(n+1)(n+2)}{6}-\frac{n(n+1)}{2}*n$ 将n作为小的数,枚举n即可. #include<iostream> #i…
discription Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). Then Sereja marked each point with a small or large English letter. Sereja don't like letter "x", so he didn't use it to mark points. Sereja thi…
Codeforces 1178D (思维+数学) 题面 给出正整数n(不一定是质数),构造一个边数为质数的无向连通图(无自环重边),且图的每个节点的度数为质数 分析 我们先构造一个环,每个点的度数都是2.但由于n不一定是质数,我们还需要再加k条边.然后对于\(i \in [1,k]\),我们加边(i,i+n/2).当\(k\leq \frac{n}{2}\)的时候,只会把一些点的度数由2变成3,否则会出现重边问题.假设新图的边数为m,那\(m \in [n,n+\frac{n}{2}]\),如果…
题目链接:http://codeforces.com/problemset/problem/627/A 题意: 告诉你s 和 x,a + b = s    a xor b = x   a, b > 0. 让你求符合条件的a b有多少对 思路: a + b = s , a ^ b = x   ==>   s - x = (a & b) * 2 #include <bits/stdc++.h> using namespace std; typedef long long LL;…
贡献了一列WA.. 数学很神奇啊 这个题的关键是怎么才能算尾0的个数 只能相乘 可以想一下所有一位数相乘 除0之外,只有2和5相乘才能得到0 当然那些本身带0的多位数 里面肯定含有多少尾0 就含有多少对2和5 这样就知道了 就是求2和5 的对数最少的 一条路 DP就不用说了 递推 注意有0的时候的计算  特殊处理一下 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm&…
Maximal GCD 题目链接:http://codeforces.com/contest/803/problem/C 题目大意: 给你n,k(1<=n,k<=1e10). 要你输出k个数,满足一下条件: ①这k个数之和等于n ②每个满足①条件的数列有最大公约数q,输出q最大的数列. 思路: 我们只需要找出这个最大的q是什么.q满足: ①q是n的 公约数 ②n/q>=(1+2+3+···+k) ③q是满足①②中的最大的 只需要通过for(long long i=1;i<sqrt(…
A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads. Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through the roads. But…
C - Two Squares 思路: 点积叉积应用 代码: #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long #define mp make_pair #define pb push_back #define ls rt<<1, l, m #define rs rt<<1|1…
B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed th…
题目链接:http://codeforces.com/problemset/problem/215/B Description The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of r1 cm, inner radius of r2 cm, (0 < r2 < r1) made of metal wi…
地址:http://codeforces.com/contest/660/problem/A 题目: A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array of n elements, you must make it a co-prime array…
传送门: http://codeforces.com/problemset/problem/598/A A. Tricky Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem you are to calculate the sum of all integers from 1 to n, b…
题目链接:http://codeforces.com/problemset/problem/448/C 题意: 给你n个数字,给定m. 问你是否能从中选出若干个数字,使得这些数字之和为m的倍数. 题解: 其实就是要找一些数字,使得之和mod m为0. 开一个vector,存当前已经能够构成的数字之和mod m之后的值. 一开始vector为空,然后枚举n个数字a[i],对于每个数字枚举当前vector中的值v[i],将没有出现过的(a[i]+v[i])%m值加入vector中. 最后判断下vec…
题目链接:http://codeforces.com/contest/872/problem/C 题意: 给你一个数n,问你最多能将n分解成多少个合数之和.(若不能分解,输出-1) 题解: 若要让合数个数最多,则n必定只由4,6,9组成. n由n/4和n%4两部分组成. 四种情况: (1)n%4 == 0: 全分成4就好了,所以ans = n/4 (2)n%4 == 1: 剩下的1要和两个4组合成一个9. 所以如果n/4 >= 2,ans = n/4 - 1 否则ans = -1 (3)n%4…
http://codeforces.com/problemset/problem/599/D 题目大意:给你一个数k  让你求一个n*m的矩形里面包含k个正方形   输出有几个这样的矩形  分别是什么 可以推出一个数学公式 我们枚举i*i的正方形  这个正方形里面的包含的正方形是有(i*i)+(i-1) *( i-1)+(i-2)*(i-2)+...+(1*1)   就等于b=i*(i-1)*(2*i-1)/6; 如果k>b  说明这个正方形里面的正方形是不够的  我们需要再添加n个(1*i)的…
题目链接:http://codeforces.com/problemset/problem/567/C C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves geometric progressions very much. Since he was on…
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following proble…
题目:http://codeforces.com/contest/1189/problem/E 题意:给定$n$个互不相同数,一个$k$和一个质数$p$.问这$n$个数中有多少对数$(a_i+a_j)(a_i^2+a_j^2)\equiv k\,mod\,p$ 思路:这一场的题目好像都很思维啊,代码量不多,想得出来就能写. 同余式左右两边同乘一个非零的数同余式不变,所以原式可以变为 $(a_i-a_j)(a_i+a_j)(a_i^2+a_j^2)\equiv (a_i-a_j)k = (a_i^…
题目链接: https://codeforces.com/gym/101194 题意: 在$n×m$的各自中填上$1$到$k$的数 定义Greate cell为严格大于同行和同列的格子 定义$A_g$为存在$g$个Greate cell的方案数 求$\sum_{g=0}^{nm}(g+1)*A_g$ 数据范围: $1\leq n \leq 200$ $1\leq m \leq 200$ $1\leq k \leq 200$ 分析: $\sum_{g=0}^{nm}(g+1)*A_g=\sum_{…
题目链接:https://codeforc.es/contest/1045/problem/F 题意:先给出一个系数不确定的二元多项式,Borna可以给这个多项式的每一项填上正的系数,Ani能从这个多项式中删除一项.询问删除一项后该多项式是否存在下界(即最小值趋向于\(-\infty\)还是等于一个不为无穷小的数值). 题解:首先我们可以发现偶数项(x项和y项次数均为偶)都存在下界,只有奇数项(x项和y项)可以不存在下界,问题就是如何判断奇数项能否导出\(-\infty\). 然后经过一通分(乱…