首页 > 其他 > 详细

URAL 1157. Young Tiler (数学啊 )

时间:2015-03-22 21:03:41      阅读:331      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1157



1157. Young Tiler

Time limit: 1.0 second
Memory limit: 64 MB
One young boy had many-many identical square tiles. He loved putting all his tiles to form a rectangle more, than anything in the world — he has learned the number of all rectangles he can form using his tiles. On his birthday he was presented a number of new tiles. Naturally, he started forming rectangles from these tiles — the thing he loved most of all! Soon he has learned all rectangles he could form with a new number of tiles.
Here we should notice that boy can easily count the number of rectangles, but he has difficulty counting the number of tiles — there are too much of them for such a young boy. But it will not be difficult for you to determine how many tiles he has now, knowing how many rectangles he could form before, how many rectangles he can form now, and how many tiles he got as a birthday present.
You are given numbers MN and K. You should find the smallest number L, such as you can form Ndifferent rectangles using all L tiles, and form M rectangles using L ? K tiles.

Input

One line containing three integers: MNK (1 ≤ MNK ≤ 10000).

Output

If L is less than or equal to 10000, then print that number (if there is a number of such L, you should print the smallest one). If there is no solution or smallest L is greater than 10000, print 0.

Sample

input output
2 3 1
16



题意:

一个年轻的瓦工,用很多瓦片拼矩形,给出M,N,K(0 < M,N,K ≤ 10000),要求出最小的瓦片数L,使L片瓦片可以拼出N种矩形,L-K片瓦片可以拼出M种矩形。
如果l小于10000,则输出l,否则输出0
样例输入:
2 3 1
样例输出:
16
样例解释:16(L)片瓦片可以拼出3种(1*16,2*8,4*4),15(L-K)片瓦片可以拼出2种(1*15,3*5)


代码如下:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int findd(int num)
{
    if(num < 0)
        return -1;
    int cont = 0;
    for(int i = 1; i <= sqrt(num*1.0); i++)
    {
        if(num%i == 0)
        {
            cont++;
        }
    }
    return cont;
}
int main()
{
    int m, n, k;
    while(~scanf("%d%d%d",&m,&n,&k))
    {
        int ans = 0;
        for(int i = 1; i <= 10000; i++)
        {
            if(findd(i)==n && findd(i-k)==m)
            {
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


URAL 1157. Young Tiler (数学啊 )

原文:http://blog.csdn.net/u012860063/article/details/44540883

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!