建议改小时限 / 改大数据。
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int, int> pr;
#define up(i, l, r) for(int i = (l); i <= (r); i++)
#define down(i, r, l) for(int i = (r); i >= (l); i--)
const int mod = 1000000007;
const int base = 2333;
const double eps = 1e-6;
inline int read() {
int x = 0, f = 1; char ch = getchar();
while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
return x * f;
}
int t, n, m, k, Q, T, _, ans = 0, cnt = 0;
int a[1000007];
bool flag = 0;
signed main() {
n = read();
cnt = n / 3 + n / 5 - n / 15;
while(1) {
t = n + cnt;
cnt = 0;
for(int i = n + 1; i <= t; i++)
if(i % 3 == 0 || i % 5 == 0) cnt++;
if(cnt == 0) {
cout << t;
return 0;
}
n = t;
}
return 0;
}