Codeforces Round #387 (Div. 2)A. Display Size(水题)
来源:互联网 发布:多人会议软件 编辑:程序博客网 时间:2024/06/10 18:49
题目:
A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels.
Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels a and the number of columns of pixels b, so that:
- there are exactly n pixels on the display;
- the number of rows does not exceed the number of columns, it means a ≤ b;
- the difference b - a is as small as possible.
The first line contains the positive integer n (1 ≤ n ≤ 106) — the number of pixels display should have.
Print two integers — the number of rows and columns on the display.
8
2 4
64
8 8
5
1 5
999999
999 1001
In the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.
In the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.
In the third example the minimum possible difference equals 4, so on the display should be 1 row of 5 pixels.
#include <stdio.h>#include <string.h>#include <stack>#include <cmath>#include <queue>#include <algorithm>#define mem(a,b) memset(a,b,sizeof(a))using namespace std;int main(){ int n; while(~scanf("%d",&n)) { for(int i=sqrt(n); i<=n; i++) { if(n%i==0) { int a=i,b=n/i; printf("%d %d\n",a>b?b:a,a<b?b:a); break; } } } return 0;}开个根号遍历就行喽~
- Codeforces Round #387 (Div. 2)A. Display Size(水题)
- Codeforces Round #387(Div. 2)A. Display Size【暴力】
- Codeforces Round #387 (Div. 2) 747A Display Size
- Codeforces Round #387 (Div. 2) A. Display Size
- Codeforces Round #387 (Div. 2)A~D A Display Size D Winter Is Coming
- Codeforces Round #387 (Div. 2)A. Display Size(简单数学)
- 【codeforces 747A】Display Size
- Codeforces Round #387 (Div. 2) A---D
- Codeforces Round #387 (Div. 2) A
- A. Display Size 水题
- 【74.00%】【codeforces 747A】Display Size
- Codeforces Round #387 (Div. 2) A+B+C+D!
- <Codeforces Round #147 (Div. 2)>A. Free Cash(水题)
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)
- Codeforces Round #261 (Div. 2) A. Pashmak and Garden (水题)
- Codeforces Round #278 (Div. 2) A. Giga Tower(水题)
- Codeforces Round #182 (Div. 2)A(水题)
- [水题]Codeforces Round #307 (Div. 2) A.GukiZ and Contest
- left join后面加上where条件浅析
- STM32 HardFault_Handler错误定位方法
- 欢迎使用CSDN-markdown编辑器
- JVM调优:新一代的垃圾回收算法
- struts2_第一节 初识mvc
- Codeforces Round #387 (Div. 2)A. Display Size(水题)
- CheckboxSelectionModel属性
- usb-OTG-ADP-HNP-SRP
- angular2.0如何使用管道?
- iOS 程序启动时总会调用application:didFinishLaunchingWithOptions:,其中第二个参数launchOptions为NSDictionary类型的对象,里面存储
- Compute the height of a binary search tree
- 安卓关于ANR的可能情况
- C++函数重载
- NOIP 提高组 初赛 四、阅读程序写结果 习题集(五)NOIP2006-NOIP2007