0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:28:48 +00:00

C - Long Sequence

https://atcoder.jp/contests/abc220/submissions/26156831
This commit is contained in:
Baoshuo Ren 2021-09-26 21:00:15 +08:00 committed by Baoshuo Ren
parent ceaf708b95
commit 8a288eac3f
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

33
AtCoder/ABC220/C/C.cpp Normal file
View File

@ -0,0 +1,33 @@
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005], b, x, s, ans;
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b += a[i];
}
cin >> x;
s = (x / b) * b;
ans = (x / b) * n;
if (x % b == 0) {
cout << ++ans << endl;
exit(0);
}
for (int i = 1; i <= n; i++) {
s += a[i];
if (s > x) {
ans += i;
break;
}
}
cout << ans << endl;
return 0;
}