URAL 1157. Young Tiler (数学啊 )
2015-03-22 20:17
344 查看
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1157
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 M, N 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.
than 10000, print 0.
题意:
一个年轻的瓦工,用很多瓦片拼矩形,给出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)
代码如下:
1157. Young Tiler
Time limit: 1.0 secondMemory 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 M, N 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: M, N, K (1 ≤ M, N, K ≤ 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 greaterthan 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 1727. Znaika's Magic Numbers(数学 vector)
- ural 2032 Conspiracy Theory and Rebranding (数学水题)
- URAL 1731. Dill(数学啊 )
- (组合数学3.3.2.1)URAL 1091. Tmutarakan Exams(容斥定理)
- URAL 1617. Flat Spots(数学啊 )
- URAL 1510. Order(map 数学啊)
- URAL 1984. Dummy Guy(数学啊)
- URAL 1309 Dispute (数学+推导)
- URAL 1515 Cashmaster 数学题
- URAL 1718 . Rejudge(数学啊 )
- URAL 1551. Sumo Tournament(数学啊 )
- 【数学题】【网络流】风扇 blower ural1765
- ural 2029 Towers of Hanoi Strike Back (数学找规律)
- URAL 1613. For Fans of Statistics(STL 数学啊 )
- URAL 1161 Stripies(数学+贪心)
- URAL 1962 In Chinese Restaurant 数学
- URAL 2067-数学
- URAL 1295. Crazy Notions(数学啊 & 找规律)
- URAL 1820. Ural Steaks(数学啊 )
- URAL 2070 Interesting Numbers(数学)