版本比较
Informatics Dream Team Beginner Contest 028 题解
正文
增加 7 行删除 7 行
1234556789101111121314156 行未改动222324252626272829303 行未改动34353637383839404142163 行未改动全部展开2062072082092102102112122132149 行未改动22422522622722822822923023123223323423523523623723823943 行未改动# A
公式:$$\text{ans} = \text{ans} =\begin{cases}n/3 & \text{if } n \% 3 == 0 \\n/3 + 1 & \text{otherwise}\end{cases}$$对 $n≥2$ 都成立。 对 $n≥2$ 都成立。
# B
因为时间无限,因此只需要找到小明可以做的练习册然后把价值相加即可。6 行未改动 int n,m,v[505],d[505],ans=0; cin >>n>>m; for(int i=1;i<=n;i++) cin >>v[i]>>d[i]; for(int i=1;i<=n;i++){ if(d[i]<=m) ans+=v[i]; if(d[i]<=m) ans+=v[i]; } cout <<ans; return 0;}3 行未改动
观察函数的形式,发现是递推,容易得到:
$$\text{g(x)} = \text{g(x)} =\begin{cases}y & \text{if } x=1 \\y^2(1+2+3+...+x-1) & \text{otherwise}\end{cases}163 行未改动全部展开 pos = std::upper_bound(a.begin() + 1, a.end(), pos + x) - a.begin(); if (pos == a.end() - a.begin()) break; pos = a[pos]; }
return ans;}
void solve() {9 行未改动 for (int i = 0; i <= 553; i++) { ans = std::min(ans, check(i)); } std::cout << ans << '\n';} }
signed main() { std::ios::sync_with_stdio(0); std::cout.tie(0); std::cin.tie(0);
i64 t = 1; i64 t = 1; // std::cin >> t; while (t--) { solve(); }43 行未改动