zoukankan      html  css  js  c++  java
  • Ifter Party LightOJ

    题意:有C个人,给P个食物,每人吃Q个,剩L个。然后给你P和L(Q>L),让你求Q的可能情况,如果有多种可能,从小到大输出;如果不存在,输出impossible

    就是求写出公式 遍历c求P-L的因子就出来了

    用set 正好

    #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 = 10010, INF = 0x7fffffff;
    set<LL> s;
    int main()
    {
        int T, kase = 0;
        scanf("%d",&T);
        while(T--)
        {
            s.clear();
            LL p, l;
            scanf("%lld%lld",&p,&l);
            for(LL i=1; i * i<=p-l; i++)
                if((p-l)%i == 0)
                {
                    if(i > l)
                        s.insert(i);
                    if((p-l)/i > l)
                        s.insert((p-l)/i);
                }
    
            printf("Case %d:",++kase);
            if(s.empty())
                printf(" impossible");
            else
                for(set<LL>::iterator it = s.begin(); it!=s.end(); it++)
                {
                    printf(" ");
                    printf("%lld",*it);
                }
            printf("
    ");
        }
    
    
        return 0;
    }
    题意:有C个人,给P个食物,每人吃Q个,剩L个。然后给你P和L(Q>L),让你求Q的可能情况,如果有多种可能,从小到大输出;如果不存在,输出impossible
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    Maven跳过测试
    Maven教程
    使用订单号加锁
    SpringMVC重定向路径中带中文参数
    并发文章
    maven clean插件使用进阶
    线程池基础
    Session中短信验证码设置有效时间
    Linux命令
    下载并安装Cent OS 6.5
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9341686.html
Copyright © 2011-2022 走看看