413:Calling Extraterrestrial Intelligence Again(翻译 )

来源:http://noi.openjudge.cn/ch0207/413/

Calling Extraterrestrial Intelligence Again

总时间限制: 

1000ms

内存限制: 

65536kB

描述

A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November 16, 1974. The message consisted of 1679 bits and was meant to be translated to a rectangular picture with 23 x 73 pixels. Since both 23 and 73 are prime numbers, 23 x 73 is the unique possible size of the translated rectangular picture each edge of which is longer than 1 pixel. Of course, there was no guarantee that the receivers would try to translate the message to a rectangular picture. Even if they would, they might put the pixels into the rectangle incorrectly. The senders of the Arecibo message were optimistic.

We are planning a similar project. Your task in the project is to find the most suitable width and height of the translated rectangular picture. The term "most suitable" is defined as follows. An integer m greater than 4 is given. A positive fraction a/b less than or equal to 1 is also given. The area of the picture should not be greater than m. Both of the width and the height of the translated picture should be prime numbers. The ratio of the width to the height should not be less than a/b nor greater than 1. You should maximize the area of the picture under these constraints.

In other words, you will receive an integer m and a fraction a/b. It holds that m > 4 and 0 < a/b <= 1. You should find the pair of prime numbers p, q such that pq <= m and a/b <= p/q <= 1, and furthermore, the product pq takes the maximum value among such pairs of two prime numbers. You should report p and q as the "most suitable" width and height of the translated picture.

输入

The input is a sequence of at most 2000 triplets of positive integers, delimited by a space character in between. Each line contains a single triplet. The sequence is followed by a triplet of zeros, 0 0 0, which indicates the end of the input and should not be treated as data to be processed.

The integers of each input triplet are the integer m, the numerator a, and the denominator b described above, in this order. You may assume 4 < m <= 100000 and 1 <= a <= b <= 1000.

输出

The output is a sequence of pairs of positive integers. The i-th output pair corresponds to the i-th input triplet. The integers of each output pair are the width p and the height q described above, in this order.

Each output line contains a single pair. A space character is put between the integers as a delimiter. No other characters should appear in the output.

样例输入

5 1 2
99999 999 999
1680 5 16
1970 1 1
2002 4 11
0 0 0

样例输出

2 2
313 313
23 73
43 43
37 53

翻译:


‎1974年11月16日星期六下午,通过波多黎各的阿雷西博射电望远镜向外星智能发出了人类的信息。该消息由 1679 位组成,旨在转换为具有 23 x 73 像素的矩形图片。由于 23 和 73 都是质数,因此 23 x 73 是平移矩形图片的唯一可能大小,其每个边缘的长度都超过 1 个像素。当然,不能保证接收者会尝试将消息转换为矩形图片。即使他们这样做,他们也可能会错误地将像素放入矩形中。阿雷西博信息的发送者是乐观的。‎

‎我们正在计划一个类似的项目。您在项目中的任务是找到翻译后的矩形图片的最合适的宽度和高度。"最合适"一词的定义如下。给出大于 4 的整数 m。还给出了小于或等于 1 的正分数 a/b。图片的面积不应大于 m。翻译图片的宽度和高度都应该是素数。宽度与高度的比率不应小于 a/b,也不应大于 1。在这些约束下,应最大化图片的面积。‎

‎换句话说,您将收到一个整数 m 和一个小数 a/b。它认为 m > 4 和 0 < a/b < = 1。您应该找到一对质数 p, q,使得 pq <= m 和 a/b <= p/q <= 1,此外,乘积 pq 在两个素数对中取最大值。您应该将 p 和 q 报告为翻译图片的"最合适"宽度和高度。‎

输入

‎输入是最多包含 2000 个正整数三元组的序列,由中间的空格字符分隔。每行包含一个三元组。该序列后跟一个零三元组 0 0 0,表示输入的结束,不应被视为要处理的数据。‎

‎每个输入三元组的整数是上述整数 m、分子 a 和分母 b,按此顺序排列。您可以假设 4 < m < = 100000,1 < = a < = b < = 1000。‎

输出

‎输出是一对正整数序列。第 i 个输出对对应于第 i 个输入三元组。每个输出对的整数是上述宽度 p 和高度 q,按此顺序排列。‎

‎每条输出线包含一对。空格字符作为分隔符放在整数之间。输出中不应显示任何其他字符。‎

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误通常出现在 UG NX 二次开发中使用“回调函数”进行异步操作时。具体原因可能是在回调函数中调用了“KI”(Kernel Interface)函数,而前一个 KI 函数尚未完成,导致了这个错误。 解决方案是在回调函数中不要直接调用 KI 函数,而是将需要调用的 KI 函数加入到队列中,等待前一个 KI 函数完成后再执行下一个 KI 函数。以下是一个示例代码: ```c++ // 定义队列 std::queue<std::function<void()>> g_kiQueue; // 定义互斥锁 std::mutex g_kiMutex; // 将需要执行的 KI 函数加入队列 void AddToKIQueue(std::function<void()> func) { std::lock_guard<std::mutex> lock(g_kiMutex); g_kiQueue.push(func); } // 在主循环中调用,执行队列中的 KI 函数 void ProcessKIQueue() { std::lock_guard<std::mutex> lock(g_kiMutex); while (!g_kiQueue.empty()) { auto func = g_kiQueue.front(); g_kiQueue.pop(); func(); } } // 回调函数示例 void MyCallback(void* userData) { // 将需要执行的 KI 函数加入队列 AddToKIQueue([](){ // 调用 KI 函数 UF_CAM_ask_machine_tool_definition(...); }); } ``` 在上面的示例中,我们使用了一个队列和一个互斥锁来实现异步执行 KI 函数。在回调函数中,我们将需要执行的 KI 函数加入到队列中。在主循环中,我们调用 `ProcessKIQueue` 函数来执行队列中的 KI 函数。这样就可以避免在回调函数中直接调用 KI 函数而导致的“KI before the previous call completes”错误。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值