NOI数学:原根和指数

原根--解题报告 sn0823T1

原根--解题报告 sn0823T1_关祺-CSDN博客

timus 1268 原根

timus 1268 原根_韩小侠的专栏 已迁移至lssea.com-CSDN博客

Ural 1268. Little Chu 求原根

Ural 1268. Little Chu 求原根_停不下的脚步-CSDN博客

1284 Primitive Roots 求原根,欧拉函数

1284 Primitive Roots 求原根,欧拉函数_kongming_acm的专栏-CSDN博客

POJ 1284 Primitive Roots 原根(欧拉函数)

POJ 1284 Primitive Roots 原根(欧拉函数)_代码改变世界,keep coding。-CSDN博客

POJ 1284 - Primitive Roots (原根 + 欧拉函数)

POJ 1284 - Primitive Roots (原根 + 欧拉函数)_无知而狂妄-CSDN博客

poj 1284 Primitive Roots 【原根】【数论】_100days-CSDN博客

poj1284 Primitive Roots(原根,欧拉函数)_Iguodala的博客-CSDN博客

POJ 1284-Primitive Roots(欧拉函数求原根个数)_Rocky0429-CSDN博客

POJ 1284 Primitive Roots 原根_嗯。-CSDN博客

【POJ1284】Primitive Roots 原根和指数_chty_syq的博客-CSDN博客

51nod1135 原根+模板

51nod1135 原根+模板_sxh759151483的博客-CSDN博客

51nod 1135 原根(数论)_BBHHTT的博客-CSDN博客

原根和离散对数BSGS求法(高次同余方程)

原根和离散对数BSGS求法(高次同余方程)_zjyang12345的博客-CSDN博客

【CF#303D】Rotatable Number 原根和指数

【CF#303D】Rotatable Number 原根和指数_chty_syq的博客-CSDN博客

信息安全数学基础(五):原根与指标

信息安全数学基础(五):原根与指标_不会vector的博客-CSDN博客

数论之指数和原根_只想躺平不想动-CSDN博客_指数 数论

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是使用C#实现小步大步算法的示例代码: ```csharp using System; using System.Numerics; namespace SmallStepBigStep { class Program { static void Main(string[] args) { Console.Write("Enter the modulus: "); BigInteger modulus = BigInteger.Parse(Console.ReadLine()); Console.Write("Enter the exponent: "); BigInteger exponent = BigInteger.Parse(Console.ReadLine()); Console.Write("Enter the primitive root: "); BigInteger primitiveRoot = BigInteger.Parse(Console.ReadLine()); BigInteger result = SmallStepBigStep(modulus, exponent, primitiveRoot); Console.WriteLine($"The result is: {result}"); } static BigInteger SmallStepBigStep(BigInteger modulus, BigInteger exponent, BigInteger primitiveRoot) { BigInteger m = (BigInteger)Math.Ceiling(Math.Sqrt((double)modulus)); BigInteger[] table = new BigInteger[m]; // Precompute table of powers of primitive root table[0] = 1; for (int i = 1; i < m; i++) { table[i] = (table[i - 1] * primitiveRoot) % modulus; } // Compute inverse of primitive root BigInteger inverse = BigInteger.ModPow(primitiveRoot, modulus - 2, modulus); // Compute small steps BigInteger[] smallSteps = new BigInteger[m]; BigInteger value = exponent; for (int i = 0; i < m; i++) { smallSteps[i] = value; value = (value * inverse) % modulus; } // Search for match between small steps and big steps value = 1; for (int i = 0; i < m; i++) { int j = Array.IndexOf(table, value); if (j >= 0) { return i * m + j; } value = (value * primitiveRoot) % modulus; } return -1; // No match found } } } ``` 在此示例中,我们使用 `BigInteger` 类型处理大整数运算。用户需要输入模数、指数原根。程序将使用小步大步算法计算指数的离散对数,并输出结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dllglvzhenfeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值