题解归档 - cf104118A
本文最后由方少年更新于2026 年 6 月 28 日,已超过0天没有更新。如果文章内容或图片资源失效,请留言反馈,将会及时处理,谢谢!
题解归档 - cf104118A
本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。
- 本地编号:
cf104118A - 本地来源:
problems/cf104118A/idea.md - 题目链接:https://codeforces.com/gym/104118/problem/A
- 原始标题:cf104118A - An Easy Calculus Question
思路
cf104118A - An Easy Calculus Question
The full statement is in contests/104118/statements.pdf because the HTML page only contains samples.
Use the constants given by the statement hint:
a=-2,b=1,c=-14,d=17.
Then evaluate the piecewise function:
x <= -3:-(x+4)^2+8-3 < x <= 2:-2x+1x > 2:x^3-14x+17
Input x is an integer in [-10,10], and the answer is always integer.
代码
来源:problems/cf104118A/solution.cpp
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll x;
cin>>x;
ll ans;
if(x<=-3) ans=-(x+4)*(x+4)+8;
else if(x<=2) ans=-2*x+1;
else ans=x*x*x-14*x+17;
cout<<ans<<"\n";
return 0;
}
~ ~ The End ~ ~
文章标题:题解归档 - cf104118A
文章链接:https://www.fangshaonian.cn/archives/166/
最后编辑:2026 年 6 月 28 日 19:03 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)