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}

1≤a,b,n≤1018

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

using namespace std;

typedef long long LL;

typedef unsigned long long uLL;

typedef pair 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;

}

.

精彩链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: