逐至 2021-04-07 09:33 采纳率: 100%
浏览 73
已采纳

c# 编程题,进链接查看文本,会的留下代码,注意important,最好带注释,感谢

链接: https://pan.baidu.com/s/108MeTLiz3iqYZCvcdbePIw

提取码: b5sn 

  • 写回答

2条回答 默认 最新

  • ProfSnail 2021-04-07 10:08
    关注
    using System;
    
    namespace ConsoleApp1
    {
        class Program
        {
            public static int Montgomery(int a, string b, int c)
            {
                if (b.Length == 0)
                {
                    return 1;
                }
                int k = a % c;
                if (b[b.Length - 1] == '0')
                {
                    a = (k * k) % c;
                    b = b.Substring(0, b.Length - 1);
                    return Montgomery(a, b, c);
                }
                else
                {
                    char[] temp = b.ToCharArray();
                    temp[b.Length - 1] = '0';
                    b = new string(temp);
                    return (k * Montgomery(a, b, c)) % c;
                }
            }
            static void Main(string[] args)
            {
    			String a = Console.ReadLine();
    			String b = Console.ReadLine();
    			int aa;
    			if(a.Length > 2)
                {
    				aa = int.Parse(a.Substring(a.Length - 2));
    			}
                else
                {
    				aa = int.Parse(a);
                }
                string c = Montgomery(aa, b, 100).ToString().PadLeft(2, '0');
                Console.WriteLine(c);
    		}
        }
    }
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大