第十三届蓝桥杯 C++ B组省赛 C 题——刷题统计(AC)

1.刷题统计

1.题目描述

小明决定从下周一开始努力刷题准备蓝桥杯竞赛。他计划周一至周五每天 做

a

a

a 道题目, 周六和周日每天做

b

b

b 道题目。请你帮小明计算, 按照计划他将在 第几天实现做题数大于等于

n

n

n 题?

2.输入格式

输入一行包含三个整数

a

,

b

a,b

a,b

n

n

n.

3.输出格式

输出一个整数代表天数。

4.样例输入

10 20 99

5.样例输出

8

6.数据范围

1

a

,

b

,

n

1

0

18

1≤a,b,n≤10^{18}

1a,b,n1018

7.原题链接

刷题统计

2.解题思路

从数据范围来看,我们肯定不能模拟,我们可以计算出一周小明可以刷多少题

w

w

w,那么可求出

w

=

5

a

+

2

b

w=5a+2b

w=5a+2b。那么可以在

O

(

1

)

O(1)

O(1)的时间内计算出小明需要完整的刷多少周的题,最少再单独模拟需要刷多少天,模拟的天数肯定不超过七天。
时间复杂度

O

(

1

)

O(1)

O(1)

3.Ac_code

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> PII;
#define pb(s) push_back(s);
#define SZ(s) ((int)s.size());
#define ms(s,x) memset(s, x, sizeof(s))
#define all(s) s.begin(),s.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int N = 200010;

LL a, b, n;
void solve()
{
	cin >> a >> b >> n;
	LL w = a * 5 + 2 * b;
	LL g = n / w;
	n %= w;
	LL ans = g * 7;
	if (n) {
		for (int i = 1; i <= 7; ++i) {
			if (i <= 5) n -= a;
			else n -= b;
			ans++;
			if (n <= 0) break;
		}
	}
	cout << ans << 'n';
}
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

.

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>