题解 P4956 【[COCI2017-2018#6] Davor】
题目描述:
在征服南极之后,Davor 开始了一项新的挑战。下一步是在西伯利亚、格林兰、挪威的北极圈远征。他将在 2018 年 12 月 31 日开始出发,在这之前需要一共筹集 n 元钱。他打算在每个星期一筹集 xx 元,星期二筹集 x+k 元,……,星期日筹集 x+6k 元,并在 52 个星期内筹集完。其中 x,k 为正整数,并且满足 1001≤x≤100。
现在请你帮忙计算 x,kx,k 为多少时,能刚好筹集 nn 元。
如果有多个答案,输出 xx 尽可能大,kk 尽可能小的。
输入格式 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 ).
输入输出样例:
输入
1456
输出
1
1 输入
6188
输出
14
1 输入
40404
输出
99
4
上代码:
#include<bits/stdc++.h>
using namespace std;
long long n;
int x,y;
int main()
{
cin>>n;
n/=52;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=100;j++)
{
if(j*7+i*21==n)
{
cout<<j<<endl<<i;
return 0;
}
}
}
}