zoukankan      html  css  js  c++  java
  • LightOJ

    链接:

    https://vjudge.net/problem/LightOJ-1116

    题意:

    Ekka and his friend Dokka decided to buy a cake. They both love cakes and that's why they want to share the cake after buying it. As the name suggested that Ekka is very fond of odd numbers and Dokka is very fond of even numbers, they want to divide the cake such that Ekka gets a share of N square centimeters and Dokka gets a share of M square centimeters where N is odd and M is even. Both N and M are positive integers.

    They want to divide the cake such that N * M = W, where W is the dashing factor set by them. Now you know their dashing factor, you have to find whether they can buy the desired cake or not.

    思路:

    考虑,奇数*偶数不可能为奇数。
    将n/2变成奇数即可。

    代码:

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<math.h>
    #include<vector>
    
    using namespace std;
    typedef long long LL;
    const int INF = 1e9;
    
    const int MAXN = 1e6+10;
    const int MOD = 1e9+7;
    
    int main()
    {
        int t, cnt = 0;
        LL n, x;
        scanf("%d", &t);
        while(t--)
        {
            scanf("%lld", &n);
            printf("Case %d: ", ++cnt);
            if (n%2)
                puts("Impossible");
            else
            {
                LL tmp = n;
                while(n%2==0)
                    n/=2;
                printf("%lld %lld
    ", n, tmp/n);
            }
        }
    
        return 0;
    }
    
  • 相关阅读:
    HTTP状态码的详细解释,供参考
    js中实现页面跳转(返回前一页、后一页)
    CRUD工程师——基础容器LinkedList
    CRUD工程师——基础容器ArrayList
    Servlet入门
    Linux
    flex弹性布局
    div布局
    递归函数
    运算符
  • 原文地址:https://www.cnblogs.com/YDDDD/p/11817278.html
Copyright © 2011-2022 走看看