HDU1239   Calling Extraterrestrial Intelligence Again

STM32G474实战:数字LLC电源控制程序从零到跑通(附完整代码解析) 本文详细介绍了基于STM32G474微控制器开发数字LLC电源控制程序的完整实战流程。从硬件平台搭建、CubeMX工程配置,到核心控制逻辑、双速率中断框架、数字PID实现,再到Burst模式、状态机等高级策略与异常处理,提供了从零到跑通的系统化指南与代码解析,助力开发者掌握高效数字电源的程序编写与调试技巧。 阅读详情

Calling Extraterrestrial Intelligence Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4014    Accepted Submission(s): 2110


Problem Description
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 * 73 pixels. Since both 23 and 73 are prime numbers, 23 * 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.
 

Input
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 indicated 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.
 

Output
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.
 

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

Sample Output
  
2 2 313 313 23 73 43 43 37 53
 

Source
 

Recommend
Eddy
代码如下:
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    int  a[10001],b[2000];
    int  m,i,j,k,l,h;
    double p,q,max;
    memset(a,0,sizeof(a));
    a[0]=a[1]=1;
    for(i=2,k=0;i<=10000;i++)
    {  if(a[i]==0)
        {
           for(j=2*i;j<=10000;j+=i)
              a[j]=1;
            b[k]=i;
            //cout<<i<<' ';
            k++;

        }
    }
    while(1)
    {
      cin>>m>>p>>q;
      if(m==0&&p==0&&q==0)
      break;
      for(i=k-1,max=0;i>=0;i--)
      {
           for(j=i;j>=0;j--)
           {
               if(b[i]>m||b[j]>m||b[i]*b[j]>m)
                    continue;
                if((double)b[j]/b[i]<p/q)
                    continue;

                  if(b[i]*b[j]>max)
                  {
                      max=b[i]*b[j];
                      l=b[i];
                      h=b[j];
                  }

           }

      }
      if(l<h)
      cout<<l<<' '<<h<<endl;
      else
      cout<<h<<' '<<l<<endl;
    }
    return 0;
}


FlinkCDC数据同步Bug——同步性能由于写入并行度限制无法提升问题的解决 使用FlinkCDC进行数据同步时,出现增量阶段写入并行度强制为1导致整体同步性能无法提升问题的解决方案 阅读详情

相关推荐

百度地图街景图像批量获取

由于个人研究需要在最近试了一下使用API获取百度地图街景图片,在此介绍一下基于我个人需求的百度街景批量获取方法,本文以Python编码作为主要方法,如果对零编码工具有需要的可以关注一下UA城市分析小组刚刚发布的街景图片获取工具。 街景图像用作区域细粒度空间指标测度需要解决几个问题。 1. 首先就是调用额度的限制,现在百度对于个人认证开发者每天可用的街景图像调用额度为100张,在不考虑购买额度上限(1万张600元,其实有经费的前提下可以直接考虑钞能力)的情况下动辄几千上万张的爬取数量会大大增加需要爬取的时间周

boycetoon29的博客 1万+

HDOJ1239(Calling Extraterrestrial Intelligence Again)

Calling Extraterrestrial Intelligence AgainTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1201Accepted Submission(s): 648 Problem Descript...

weixin_30306905的博客 291

Ubuntu下安装Hive3.1.2教程(附MySQL安装方法及安装包)

文章目录前言一、安装Hive1. 下载压缩包并解压2. 安装Hive3. 配置环境变量4. 修改配置文件二、MySQL安装与配置1. 安装MySQL2. 安装MySQL jdbc包3. 为Hive创建MySQL账号三、验证Hive安装及错误处理1. 启动Hadoop2. 启动hive3. 运行Hive实例总结 前言 Hive 的安装需要建立在 Hadoop 的之上(类似于Hbase),关于 Hadoop 的单机安装以及伪分布式安装可以参考作者的另两篇博客: Ubuntu下单机安装Hadoop详细教程(附

程序必须为人类阅读而编写,并且仅仅碰巧可以让机器执行 1万+

POJ 1411 Calling Extraterrestrial Intelligence Again

Calling Extraterrestrial Intelligence Again Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10716   Accepted: 4210 Description A message from humans to ext

Walk the horizon 1388

ROS应用之如何配置RTOS满足机器人系统中的实时要求

实时操作系统(RTOS)基本概念实时操作系统(RTOS)是设计用于实时应用的操作系统,其主要目标是在确定的时间内完成任务。RTOS的任务调度算法和优先级控制机制能够确保高优先级任务按时完成。精确的传感器数据采集:传感器数据需要在规定时间内采集并传输给控制系统。快速响应外部事件:对于控制系统,需要确保指令在最短的时间内得到响应。任务的调度周期:任务的周期可以通过公式计算,其中 ftask 是任务的调度频率。优先级分配。

weixin_68094467的博客 1008

使用 ArcGIS Pro 和 Google Earth Engine 可视化地表温度

在这项研究中,利用 Landsat 热数据通过各种方法检查了 2013 年和 2023 年恰纳卡莱省的地表温度变化。使用了 NDVI、大气层顶部、亮度温度、植被比例和地表温度等公式。研究结果表明,从热图像中获得的数据,特别是地表温度(LST),是土地解释的重要资源。恰纳卡莱 — 土耳其(土耳其)使用 ArcGIS 程序和 Google Earth Engine 对不同季节的卫星图像进行分析。

gis收藏家的博客 2001

HDOJ 1239:Calling Extraterrestrial Intelligence Again 解题报告

Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2905    Accepted Submission(s): 1561 Probl

PythonFX的专栏 2410

uniapp:APP报错Error: Not Found:Page[2][-1,1;-1,1,0,0,2-0] at view.umd.min.js:1(uniApp安卓苹果ios出现一大堆数字错误)

Error: Not Found:Page[2][一串数字] at view.umd.min.js:1,uniapp在APP端运行报错Error: Not Found:Page[2][-1,1;-1,1,0,0,2-0] at view.umd.min.js:1,uniapp真机运行偶尔出现Not Found:Page[2][-1,28] at view.umd.min.js:1,如何解决uniApp app报错:Not found -1,71 at view.umd.min.js:1,uniapp项目在H

✅ 精选推荐文章 3984

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 o..

qq_61838780的博客 380

电路中的DGND、GROUND、GROUND_REF的区别,VREF、VCC、VDD、VEE和VSS的区别?

DGND是数字地,是数字电路部分的公共基准端,用于连接数字电路的接地。

XU157303764的博客 2341

大模型知识边界探索:LLM设计的极限测试

最优化理论是数学中的一个分支,主要研究如何从给定的一组约束条件下找到最优解。目标函数:定义了需要优化的指标,可以是最大化或最小化。约束条件:定义了在优化过程中需要满足的限制条件。无约束优化:目标函数和约束条件都不存在。有约束优化:目标函数存在,但存在约束条件。多目标优化:同时需要优化多个目标函数。极限测试(Ultimate Test)是一种系统性的方法,用于评估大型模型(如LLM)在极端条件下的性能和稳定性。极端数据分布:与模型训练数据分布显著不同的数据集。极端计算资源。

AI天才研究院 433

2.Calling Extraterrestrial Intelligence Again

Calling Extraterrestrial Intelligence Again A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November 16

p13132312312的博客 469

出现Command ‘vim‘ is available in the following places,vim: command not found等解决方法

内置命令无法识别,说明系统变量有误,导致无法识别,既然系统变量有误,将其注释或者更改为正确的即可,但是现在打不开,又怎么注释掉。替换vim来打开编辑,打开之前错误的全局变量文件,发现变量有误,要么注释要么改为。系统变量有全局变量(通过命令行printenv或者echo)和局部变量。对应通过vim修改错误的变量文件,不然source也无法让配置文件生效。本身vim是系统内置的命令,连vim都出现问题。修改为正确的即可,之后还需要重启服务器,使用。之后即可成功,通过即可查看命令是否有写入。...

码农研究僧的博客 5883

HDU 1239 Calling Extraterrestrial Intelligence Again

HDU 1239 Calling Extraterrestrial Intelligence Again 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1239 题目大意: 两个素数 p, q 并且 p*q  4  求最大的q,p值 有上面可以得出,判断的过程并不难,把100000以内素数全部求出,然后两两判断就行了。 但是,

Kernight 772

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

HDU1239:Calling Extraterrestrial Intelligence Again

Problem Description 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 cons

ACM!荣耀之路! 3452

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

hdu 1239 Calling Extraterrestrial Intelligence Again

http://acm.hdu.edu.cn/showproblem.php?pid=1239 一道水题,只要遍历找出所有的素数,应为a,b都不大,所以直接穷举法就可以过了。#include<iostream> using namespace std; int m, a, b,l; int p[999],_p,_q; int isP(int n){ for (int i = 2; i*i <

lkj41110的博客 321

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

【筛法求素数】HDU-1239 Calling Extraterrestrial Intelligence Again

注解 1、首先用筛法求100000以内的素数,并找到其个数。 2、在所有找到的素数中,遍历找一个素数对,满足: (1)二者相乘小于等于m; (2)二者相乘是所有满足条件的素数对中的最大的; (3)二者相除大于等于a/b,并且小于等于1 代码 #include <iostream> #include <cstring> using namespace std; cons...

zhanggirlzhangboy的博客 205

HDU 1239 Calling Extraterrestrial Intelligence Again(找素数)

http://acm.hdu.edu.cn/showproblem.php?pid=1239 题目很长,长就不说了,还是英文,这么长的英文也就算了,居然还是水题,我靠,坑嗲啊!!! 题意:输入 m a b 三个数 输出:p q 要求: p q 是素数,且 p*q <=m 是 <= ,,且 a/b <=...

aocang4831的博客 158

hdu1239 Calling Extraterrestrial Intelligence Again(贪心)

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 an

qq_37816449的博客 372

hdu 1239Calling Extraterrestrial Intelligence Again

题比较简单,容易写, 但是测试数据多, 容易TL…… #include #include #include using namespace std; int pr[100001]={0}; int prime[50000]; int main() { int m, a,

tanhaiyuan 644

HDU 1239(Calling Extraterrestrial Intelligence Again)

参考博客:题目分析,代码 #include <iostream> using namespace std; int prime[2005]; //小于10000的质数 int isPrime[10005]; //是否为质数 int num; //小于10000的质数的数量 //查找小于10000的所有质数 void findPrime() { for (int i = ...

Intelligence1028的博客 149

hdu 1239 Calling Extraterrestrial Intelligence Again (暴力枚举)

Calling Extraterrestrial Intelligence Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3993    Accepted Submission(s): 2097 Problem

Hadis_yuki 1094

【HDU】 1239 Calling Extraterrestrial Intelligence Again

Calling Extraterrestrial Intelligence Again题目链接 Calling Extraterrestrial Intelligence Again 题目大意    题目名字好长~~     题目也好长~~     其实看最后一段就够了…给你三个数m,a,b 现在要你求两个质数p,q满足 ab≤pq≤1    m≥pq    max(pq) \frac{a}

S_Black的专栏 464
上一篇: HDU1238 Substrings
下一篇: HDU2199 Can you solve this equation?
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值