zoukankan      html  css  js  c++  java
  • The Bells are Ringing UVALive

    输出整数N,使得  t1 <= N  统计有多少组t1,t2,t3,满足:1<t1<t2<t3<=1000000,t3-t1<=25,且t1,t2,t3的最小公倍数是N

    枚举t1就好了

    #include <iostream>
    #include <cstdio>
    #include <sstream>
    #include <cstring>
    #include <map>
    #include <set>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #define MOD 2018
    #define LL long long
    #define ULL unsigned long long
    #define Pair pair<int, int>
    #define mem(a, b) memset(a, b, sizeof(a))
    #define _  ios_base::sync_with_stdio(0),cin.tie(0)
    //freopen("1.txt", "r", stdin);
    using namespace std;
    const int maxn = 1000000;
    
    LL gcd(LL a, LL b)
    {
        return b==0?a:gcd(b, a%b);
    }
    
    int main()
    {
        LL n;
        int kase = 0;
        while(scanf("%lld",&n) != EOF && n)
        {
            int ok = 0;
            printf("Scenario %d:
    ",++kase);
            for(LL i=1; i<=n && i<=maxn; i++)
            {
                if(n % i) continue;
                for(LL j=i+1; j<=i+25 && j<=maxn; j++)
                {
                    if(n % j) continue;
                    LL tem1 = i * j / gcd(i, j);
                    for(LL k=j+1; k<=i+25 && k <= maxn; k++)
                    {
                        if(n % k) continue;
                        LL tem2 = tem1 * k / gcd(tem1, k);
                        if(tem2 == n)
                        {
                            printf("%lld %lld %lld
    ",i,j,k);
                            ok = 1;
                        }
                    }
                }
            }
            if(!ok) printf("Such bells don't exist
    ");
    
            printf("
    ");
    
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    js复习(一)
    Webform(文件上传)
    Webform(分页与组合查询配合使用)
    Webform(分页、组合查询)
    webform(内置对象)
    Webform(内置对象-Response与Redirect、QueryString传值、Repeater删改)
    Webform(Repeater控件)
    MDI窗体容器 权限设置
    进程和线程
    WinForm三级联动
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9326977.html
Copyright © 2011-2022 走看看