当前位置: 首页 > news >正文

Legendre公式

 参考:Legendre公式:数论罪恶的开始 - 知乎

Legendre公式和Kummer定理 - tkandi - 博客园    

Legendre公式:

屏幕截图 2025-11-16 003334

 

 

解释:n是一个正整数,p是一个小于等于n的质数

输出:通过Legendre公式可得到 n! 的其中一个质数 p 的幂次

 

 

Legendre公式p - 进制形式:

image

与上式等价

 

例题:小苯的因子查询_牛客题霸_牛客网

解:

image

2是质数,通过legendre公式求解

查看代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int N = 1e6 + 5;int binpow(int a, int b){if(b == 0) return 1;int res = 1;while(b){if(b & 1) res = res * a % mod;a = a * a % mod;b >>= 1;}return res;
}void solve(){int n;cin >> n;int k = 0;//legendre公式while(n){k += n / 2;n /= 2;}cout << binpow(k + 1, mod - 2) % mod << " ";return ;
}

 

http://www.jsqmd.com/news/41388/

相关文章:

  • 字的bi-gram是个馊主意么?
  • 在Caddy 上使用php-fpm
  • KEYDIY KD ZB09 3-Button Universal Audi Smart Key PCB (5pcs/lot) - For Repair Shops Owners
  • 2025年浙江雅思培训机构评测TOP5:深耕本土的优质教育资源推荐
  • 动态调试练习题WP
  • Godot学习第一天
  • 用递归的方式解决n阶幻方
  • imm docker 备份/迁移
  • abc326-d 题解
  • 搭建一个CTF比赛平台的经过
  • 11_15
  • 四、Agent原理与ReAct 架构详解 ——《动手学Agent应用开发》学习心得
  • InterStellar
  • 三、Agent 应用开发与落地全景 ——《动手学Agent应用开发》学习心得
  • 每日反思(2025_11_15)
  • 业财一体化五步法 - 智慧园区
  • 猫树
  • 『回忆录』高二上半期考试
  • 多项式牛顿迭代
  • 轮胎内喷涂优惠工具趋势分析报告
  • Vibe coding All In One
  • 路径计数与反射容斥
  • 多项式复合逆与拉格朗日反演
  • Day21浮动
  • Spring AI Alibaba 项目源码学习(七)-Agent、BaseAgent、ReactAgent 分析
  • AtCoder Beginner Contest 432 ABCDEG 题目解析
  • fireworks
  • KEYDIY KD ZB28-3 Universal Hyundai Smart Remote Key (5pcs/lot) – Reliable Replacement
  • Yanhua Mini ACDP-2 A303 Volvo 2022+ IMMO License for ACDP-2 Module20
  • 西电TIC带鱼杯新生训练赛复盘