# [COCI2017-2018#6] Davor

## 题目描述

After successfully conquering the South Pole, Davor is preparing for new challenges. Next up is the Arctic expedition to Siberia, Greenland and Norway. He begins his travels on 31 December 2018, and needs to collect ​N kunas (Croatian currency) by then. In order to do this, he has decided to put away ​X (​X ≤ 100) kunas every Monday to his travel fund, ​X + K kunas every Tuesday, ​X + 2* ​K every Wednesday, and so on until Sunday, when he will put away ​X + 6* ​K kunas. This way, he will collect money for 52 weeks, starting with 1 January 2018 (Monday) until 30 December 2018 (Sunday).

If we know the amount of money ​N​, output the values ​X and ​K so that it is possible to collect the ​exact money amount in the given timespan. The solution will always exist, and if there are multiple, output the one with the greatest ​X ​ and smallest ​K ​.

## 输入格式

The first line of input contains the integer ​N​ (1456 ≤ ​N​ ≤ 145600), the number from the task.

## 输出格式

The first line of output must contain the value of ​X (​0 < ​X ​≤ 100 ​)​, and the second the value of
K (K ​> 0 ​)​.

## 样例 #1

### 样例输入 #1

``````1456
``````

### 样例输出 #1

``````1
1
``````

## 样例 #2

### 样例输入 #2

``````6188
``````

### 样例输出 #2

``````14
1
``````

## 样例 #3

### 样例输入 #3

``````40404
``````

### 样例输出 #3

``````99
4
``````

# 提交程序

``````import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
//获取k的可能值最大值
int num = n / 52 / 21;

int count = 0;
int max = -1;
int min = num;
//获取k的最小x的最大
for (int i = num;i > 0;i--) {
count = (n / 52 - (21 * i)) / 7;
if (count > max && count <= 100) {
max = count;
if (i < min) {
min = i;
}
}

}
System.out.println(max);
System.out.println(min);

//第二种方式
/*  int x, k;
int sum = n / 52;
for (k = 1; ; k++) {
for (x = 100; x > 0; x--) {
if (7 * x + 21 * k == sum) {
System.out.println(x + "\n" + k);
return;
}
}
}*/
}
}

``````