perechi3.in / perechi3.out We don't know how Por Costel the pig arrived at FMI's dance party. All we know is that he did. The dance floor is hot because Por Costel broke the air conditioner. On the dance floor, the boys and girls are clumsy. There ar…
Por Costel and the Pairs Descriptions 有T组测试样例 有n个男的,n个女的,第i个人都有为当前一个大小为i的懒惰值,当一男一女懒惰值的乘积<=n他们就就可以一起跳舞,请问有多少种组合可能: Example Input 1114510100991664495048 Output 18102748247350280201207198 题目链接 https://vjudge.net/problem/Gym-100923I   求n/1+n/2+...+n/n,除法…
链接: https://vjudge.net/problem/Gym-100923I 题意: We don't know how Por Costel the pig arrived at FMI's dance party. All we know is that he did. The dance floor is hot because Por Costel broke the air conditioner. On the dance floor, the boys and girls…
algoritm.in / algoritm.out Even though he isn't a student of computer science, Por Costel the pig has started to study Graph Theory. Today he's learning about Bellman-Ford, an algorithm that calculates the minimum cost path from a source node (for in…
semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from the Petrozaporksk training camp. There, he learned a lot of things: how to boil a cob, how to scratch his belly using his keyboard, etc... He almost r…
semipal.in / semipal.out Por Costel the pig, our programmer in-training, has recently returned from the Petrozaporksk training camp. There, he learned a lot of things: how to boil a cob, how to scratch his belly using his keyboard, etc... He almost r…
meciul.in / meciul.out Oberyn Martell and Gregor Clegane are dueling in a trial by combat. The fight is extremely important, as the life of Tyrion Lannister is on the line. Oberyn and Gregor are measuring their skill in combat the only way the two be…
azerah.in / azerah.out Por Costel the Pig has received a royal invitation to the palace of the Egg-Emperor of Programming, Azerah. Azerah had heard of the renowned pig and wanted to see him with his own eyes. Por Costel, having arrived at the palace,…
裸题. 看之前的模版讲解吧,这里不再赘述了. #include<cstdio> #include<cstring> using namespace std; int fa[100010]; bool rel[100010]; int n,m,T; int findroot(int x){ if(x==fa[x]){ return x; } int Fa=findroot(fa[x]); if(rel[x]==0 && rel[fa[x]]==0){ rel[x]=0…
Por Costel and Azerah Descriptions 给你n个数 问你,有多少个子序列 的和是偶数 Example Input 233 10 124 2 Output 33 题目链接 https://vjudge.net/problem/Gym-100923A   恶心死了   freopen("azerah.in","r",stdin); freopen("azerah.out","w",stdout); 必…
最近以C#为例,学习了程序设计基础,其中涉及到一些数学思维,我们可以巧妙的将这些逻辑问题转换为代码,交给计算机运算. 现将经常会使用到的基础函数做一总结,供大家分享.自己备用. 1.判断一个数是否为奇数 定义:整数中,能被2整除的数是偶数,不能被2整除的数是奇数 思路点:n%2!=0则为奇数 /// <summary> /// 判断一个整数是不是奇数 /// </summary> /// <param name="n">要判断的整数</para…
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数学题--你会你就能做,不会做就是真的做不出来QAQ 鲁迅曾说:一入数学深似海,从此AC是路人. 一些会说到的题目:(都是洛谷编号) 这些题目全都是原来NOIP考过的真题喔 1010 1014 1029 1035 1045 1075 1012 1351 2119 ok咱们开始说 第一题,洛谷P1010…
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k? 1 ? 2 ? ... ? n = k For example: to obtain k = 12 , the expression to be used will be:…
B. Tell Your World time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Connect the countless points with lines, till we reach the faraway yonder. There are n points on a coordinate plane, the i…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5923 题意: 现有 $N$ 支队伍参加比赛,只有一个队伍能获胜.给出每个队伍一个赔率 $A_i:B_i$,你往这个队投 $x$ 元,若该队获胜你可得到 $\frac{A_i+…
BUPT2017 wintertraining(15) #4F Gym - 101124A 题意 给定画框宽度,画的四边和一个对角线长度,求画框外沿周长. 题解 过顶点做画框的垂线,每个角都得到两个全等直角三角形.然后用余弦公式求得四个角,再在直角三角形中计算出比内沿多出来的长度,加上画的四边长度即可. 代码 #include <cstdio> #include <cstring> #include <algorithm> #include <cmath>…
You are given a prime number pp, nn integers a1,a2,…,ana1,a2,…,an, and an integer kk. Find the number of pairs of indexes (i,j)(i,j) (1≤i<j≤n1≤i<j≤n) for which (ai+aj)(a2i+a2j)≡kmodp(ai+aj)(ai2+aj2)≡kmodp. Input The first line contains integers n,p,…
题目链接:http://codeforces.com/gym/100923/problem/H 分析:并查集,用enemy储存x的敌人,用weight储存权重决定根节点 需用scanf和puts输入输出否则会爆 1 #include<iostream> 2 #include<sstream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<string> 6 #include<cstrin…
题目链接:http://codeforces.com/gym/100923/problem/L 分析:题目要求序列首尾相同,在此基础上的字典序第k个:因为只存在a,b所以我们把它等效成0和1的话,字典序k也就是二进制下的k,将其最后一位与序列头部相同即可 1 #include<iostream> 2 #include<sstream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<string>…
题目:传送门.(需要下载PDF) 题意:t组数据,每组数据给定一个数ni(1 ≤ ni ≤ 10^18),把ni拆成尽可能多的数,要求每个数的素因子只包含2和3,且这些数不能被彼此整除,输出一共能拆成多少个数,并输出这些数. 题解:根据题意ni = 2^a0*3^b0*+2^a1*3^b1+........+2^ax*3^bx,所以我们按照ai升序,bi降序的顺序求出每一个加数,这样会保证这些数不能被彼此整除.首先打表得知3^40会超过long long,3^39不会,先打出3^39的表存到数组…
题意:给定一个N,让你把它拆成若干个只含素因子2和3的数之和,且两两之间没有倍数关系,比如10=4+6. 思路:即是2因子的幂递增,3因子的幂递减:或者反之. 对于当前N,我们拆分出的数为num=2^x*3^y:满足2^x|N,而且y最大,然后把继续拆分N-num.不难推出,N-num是个偶数,且至少含有x+1个2之积,那么N-num的2的幂一定>x:而3的幂一定<y.      用公式不难验证:N=2^x(3^y+2*....); num=前面部分,N-num=后面部分,2因子至少多出来一个…
数同余的个数显然是要把\(i,j\)分别放到\(\equiv\)的两边 $ (a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p $ 左右两边乘上\((a_i-a_j)\) 得:\((a_i^2-a_j^2)(a_i^2+a_j^2)\equiv a_ik-a_jk \bmod p\Longrightarrow a_i^4-a_j^4\equiv a_ik-a_jk \bmod p\Longrightarrow a_i^4-a_ik\equiv a_j^4-a_…
题意:简化一下 就是解N个 系数矩阵一样 等式右边列矩阵不一样的方程组 题解:系数矩阵一样 为什么我却毫无办法???? 其实只要把等式右边的矩阵都排在后面就好了啊 就变成解一个N x 2N的方程组了 ... #include <bits/stdc++.h> using namespace std; const double eps = 1e-9; int n; double a[205][405]; void gauss() { int now = 1, to; for(int i = 1;…
意甲冠军:那是,  从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号的差值的绝对值. 算法: 题目就是要求                  watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MTg0NQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissol…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818 题目描述: Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be l…
链接:HDU - 6409:没有兄弟的舞会 题意: 题解: 求出最大的 l[i] 的最大值 L 和 r[i] 的最大值 R,那么 h 一定在 [L, R] 中.枚举每一个最大值,那么每一个区间的对于答案的贡献就是一个等差数列的和(乘法分配律),将每一个和乘起来就是该最大值的对于答案的贡献.但是相同最大值可能来自于多个区间,如果枚举每一个可能出现最大值的区间,那么会超时,所以需要一个神奇的方法,我也不知道原理是什么,但是数学上就是直接的式子,可以分解出来. #include <bits/stdc+…
链接:https://www.nowcoder.com/acm/contest/69/B来源:牛客网 蜥蜴的生日快到了,就在这个月底! 今年,蜥蜴的快乐伙伴之一壁虎想要送好多个1元硬币来恶整蜥蜴. 壁虎身上目前有的硬币种类和数量如下: c1个1元硬币.c5个5元硬币.c10个10元硬币.c50个50元硬币. 壁虎觉得只送c1个1元硬币不够慷慨,想拿一些币值较大的硬币去换更多的1元硬币,于是跑去找一台自动贩卖机,靠着买东西找零来获得更多1元硬币! 这台自动贩卖机的找零机制如下: 每件物品的价格都是…
过程很美妙啊 Problem Description Rikka is a high school girl suffering seriously from Chūnibyō (the age of fourteen would either act like a know-it-all adult, or thinks they have special powers no one else has. You might google it for detailed explanation)…
1. 题目 我的提交 GZS的三角形 发布时间: 2015年9月6日 15:18   最后更新: 2016年6月26日 12:10   时间限制: 1000ms   内存限制: 256M 描述 机智无比的G神今天完成了一天的任务,实在是无聊的紧,拿起一支笔在纸上画起了三角形,边长为1, 2, 3,......... 即使是无聊到这种程度,G神发达的大脑也在不停的思考,从顶部的点到沿着所画出的边到达底边的方案有多少种呢. 结果可能比较大, 结果对1000003取余. 例如,边长为2的情况如下所示:…
2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Acesrc is a famous mathematician at Nanjing University second to none. Playing with interesting numbers is his favorite. Today, he finds a manuscript whe…