zoukankan      html  css  js  c++  java
  • 有趣的数字算法

    输入正整数 n , 按从大到小的顺序输出所有形如 abcde/fghij = n 的表达式,其中a ~ j为0 ~ 9的数字(不可重复)。2 <= n <=79.

    样例输入:
    62

    样例输出:
    79546/01283 = 62
    94736/01528 = 62

    方法:以62为例

    private bool isRepeat(string val)
        {
            bool result = true;
            foreach(char s in val)
            {
                if (new Regex(s.ToString()).Matches(val).Count > 1)
                {
                    result = false;
                    break;
                }
            }
            return result;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int max = 98765;
            int min = max / 62;
            for (int i = 1234; i < min; i++)
            {
                if ((isRepeat((i * 62).ToString().PadLeft(5, '0') + i.ToString().PadLeft(5, '0'))))
                {
                    Response.Write((62 * i).ToString().PadLeft(5, '0') + "/" + i.ToString().PadLeft(5, '0'));
                    Response.Write("<br />");
                }
            }
        }

  • 相关阅读:
    Apache、NGINX支持中文URL
    JS中关于clientWidth offsetWidth scrollWidth 等的含义
    设置apache登陆密码验证
    通过java代码访问远程主机
    win7
    Netty从没听过到入门 -- 服务器端详解
    分块分段
    数论-佩尔方程
    数论-毕达哥拉斯三元组
    HDU 5613-Baby Ming and Binary image
  • 原文地址:https://www.cnblogs.com/94cool/p/1792212.html
Copyright © 2011-2022 走看看