2019.7.31 金华正睿集训总结Day4(ACM)

今天是ACM赛!

我真是太菜了!

A - 10^N+7

来源

You are given three non-negative integers, x, y, z. Your task is to find the smallest non-negative integer n with all of the following conditions:
· n mod 17=x
· n mod 107=y
· n mod 1000000007(=109+7)=z

这是一道签到题

用条件三枚举 n 的取值,判断是否符合前两个条件就行了

#include <bits/stdc++.h>
using namespace std;
const long long a = 17, b = 107, c = 1e9 + 7;
int main()
{
	long long n, i = 0;
	long long x, y, z;
	cin >> x >> y >> z;
	while (1)
	{
		n = i * c + z;
		if (n % a == x && n % b == y) 
		{
			cout << n << endl;
			return 0;
		}
		i++; 
	}
	return 0;
}

B - Coins

来源

There are 1-, 5-, 10-, 50-, 100-, 500- yen coins, and you have an infinite number of coins of each type.
For a given positive integer x, let f(x) be the smallest number of coins you have to use to pay exactly x yen. For example, f(2018)=9 because 2018=1+1+1+5+10+500+500+500+500.
You are given a positive integer N. Count the number of positive integers x such that f(x)=N.
1≤N≤1018

这也是道签到题

我们可以想到 5 个 1 元可以用 1 个 5 元代替,2 个 5 元可以用 1 个 10 元代替

同理,50, 100 也可以想到

因为最

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值