
算法竞赛-数论
算法竞赛-数论
Jamence
AI从业者,负责过多模态大模型、超大规模分类、聚类、检索等任务;发表过10+ CCF A/B等论文
展开
-
poj1423(斯特林公式)
Big NumberTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 28472 Accepted: 9055DescriptionIn many applications very large integers numbers are required原创 2017-08-29 21:50:52 · 500 阅读 · 0 评论 -
数论
数论数论是一个比较大的话题,慢慢更素数素数母函数母函数gcd//欧几里得,又叫做最大公约数int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int gcd(int big, int small){ if (small > big) swap(big, small); ...原创 2018-08-14 08:29:02 · 425 阅读 · 0 评论 -
hdu1521排列组合 (指数型母函数)
有n种物品,并且知道每种物品的数量。要求从中选出m件物品的排列数。例如有两种物品A,B,并且数量都是1,从中选2件物品,则排列有"AB","BA"两种。 Input每组输入数据有两行,第一行是二个数n,m(1Output对应每组数据输出排列数。(任何运算不会超出2^31的范围)Sample Input2 21 1Sample Output2指数型母原创 2017-11-25 10:15:13 · 316 阅读 · 0 评论 -
hdu2079+母函数
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2079#include using namespace std;struct node { int grades; int num;};int main(){ int ncase; cin>>ncase; while(ncase--){ int n,k; node原创 2017-06-29 21:21:42 · 466 阅读 · 0 评论 -
hdu2068错排+排列组合
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2068这道题知道了错排就比较好做了#include #include #include #include #include using namespace std; typedef long long ll;ll C(int m, int n) {原创 2017-06-29 21:13:28 · 445 阅读 · 0 评论 -
全排列的实现方法
#include #include #include using namespace std;/*递归实现(一)int n;int visit[11],ans[11];void dfs(int depth){ if(depth>n){ for(int i=1;i<=n;i++) cout<<ans[i]; cout<<endl; } else{ for(in原创 2017-05-06 08:47:52 · 416 阅读 · 0 评论 -
hdu1284钱币兑换问题 (普通型母函数)
在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sample Input293412553Sample Output71883113137761母函数,已知每一项相乘的权值增长规律,求得当幂为N的值,可以预处理一下原创 2017-11-25 09:59:28 · 483 阅读 · 0 评论 -
hdu2841 Visible Trees(容斥)
There are many trees forming a m * n grid, the grid starts from (1,1). Farmer Sherlock is standing at (0,0) point. He wonders how many trees he can see. If two trees and Sherlock are in one line,原创 2017-12-08 16:03:19 · 289 阅读 · 0 评论 -
hdu4059 The Boss on Mars(容斥)
On Mars, there is a huge company called ACM (A huge Company on Mars), and it’s owned by a younger boss. Due to no moons around Mars, the employees can only get the salaries per-year. There are n e原创 2017-12-08 15:58:00 · 399 阅读 · 0 评论 -
51nod 1284(容斥)
给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。Input输入1个数N(1 Output输出不是2 3 5 7的倍数的数共有多少。Sample Input10Sample Output1看看容斥的思想这道题目就会了。#include using namespace std;int ma原创 2017-12-08 15:48:28 · 244 阅读 · 0 评论 -
51Nod 1003 阶乘后面0的数量(后置0的个数)
n的阶乘后面有多少个0?6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0。Input一个数N(1 Output输出0的数量Input示例5Output示例1后置0的个数取决于因子2和5的个数由于2的个数远多于5的个数,于是只需要考虑因子为5的个数#include原创 2017-09-12 22:41:25 · 299 阅读 · 0 评论 -
51Nod 1004 n^n的末位数字()
给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。Input一个数N(1 Output输出N^N的末位数字Input示例13Output示例3#includeusing namespace std;int main(){ int m; cin>>m; int n=m%10; if原创 2017-09-12 22:39:48 · 293 阅读 · 0 评论 -
51Nod 1013 3的幂的和(逆元和快速幂)
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 Output输出:计算结果Input示例3Output示例40#include using namespace std;typedef long long ll;const ll mod=10000原创 2017-09-12 22:37:47 · 459 阅读 · 0 评论 -
51Nod 1016 水仙花数 V2
水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身。(例如:1^3 + 5^3 + 3^3 = 153,1634 = 1^4 + 6^4 + 3^4 + 4^4)。给出一个整数M,求 >= M的最小的水仙花数。Input一个整数M(10 Output输出>= M的最小的水仙花数,如果没有符合条件的水仙花数,则原创 2017-09-14 21:34:26 · 349 阅读 · 0 评论 -
51Nod 1012 最小公倍数LCM
输入2个正整数A,B,求A与B的最小公倍数。Input2个数A,B,中间用空格隔开。(1Output输出A与B的最小公倍数。Input示例30 105Output示例210#include using namespace std;long long gcd(long long a,long long b原创 2017-09-13 20:14:54 · 373 阅读 · 0 评论 -
51Nod 1011 最大公约数GCD
输入2个正整数A,B,求A与B的最大公约数。Input2个数A,B,中间用空格隔开。(1Output输出A与B的最大公约数。Input示例30 105Output示例15其实写之前还以为要快速GCD才不会超时,看来不是的#include using namespace std;int gcd(int a原创 2017-09-13 20:12:00 · 346 阅读 · 0 评论 -
Uva11582 Colossal Fibonacci Numbers!
传送门:https://vjudge.net/problem/UVA-11582这道题比较烦的事时unsigned long long和long long的区别,很坑呀如果是long long,由于数据太大,会出问题·而unsigned long long,由于一定是正数,即使溢出,也是对2(该题具体分析紫书上有)#include using namespace std;t原创 2017-09-18 10:49:46 · 486 阅读 · 0 评论 -
poj2480Longge's problem数论积性函数
Longge’s problem Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now a problem comes: Given an integer N(1 &l...原创 2018-08-15 15:16:17 · 578 阅读 · 0 评论