https://codeforces.com/group/5yyKg9gx7m/contest/269717/problem/B
题目描述:
分析:
可以找到规律:每15个为一个循环,1~15中跳过3和5倍数,剩下9个数。到下一个循环,就相当于每个数加15.
代码:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; int a[9]={14,1,2,4,7,8,11,13,14}; int main() { int n; cin>>n; int r=n%8; int g=n/8; if(r==0) g--; ll ans=g*15+a[r]; cout<<ans<<endl; return 0; }
原文:https://www.cnblogs.com/studyshare777/p/12405126.html