洛谷.P4956Davor

题目描述
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 ​)​.
输入输出样例

原题链接:
link.
简单的一道题,但是翻译的是侯理解错了恰好收集还是超额收集
另外需要注意的就是x的范围(小于等于100大于0),以及输出 x 尽可能大,k 尽可能小的。。
思路大体就是:两个循环遍历,从k最小范围,x最大处开始,恰好为n。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#define PI 3.1415926535
#include<functional>
#include<vector>
#include <iostream>

using namespace std;
typedef long long ll;
const int maxn=1e5;
const int N = 1e6 + 10;
const int INF = -10234567;

int main()
{
    int n, x, k;
    scanf("%d", &n);
    for (k = 1;k<n; k++)//...尴尬,找半天
        for (x = 100; x > 0; x--)
            if ((7 * x + 21 * k) * 52 == n)
            {
                printf("%d\n%d\n", x, k);
                return 0;
            }
}

emmm,就是这样了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值