jzoj4803-[NOIP2016提高A组模拟9.28]求导【模拟】
生活随笔
收集整理的這篇文章主要介紹了
jzoj4803-[NOIP2016提高A组模拟9.28]求导【模拟】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
正題
題目大意
求一個標準多項式的求導
解題思路
暴力模擬即可,注意細節即可
一下是貼心的坑爹細節樣例
(233+x)?>(1)而不是(+1)(233+x)->(1)而不是(+1)(233+x)?>(1)而不是(+1)
(1)?>(0)而不是()(1)->(0)而不是()(1)?>(0)而不是()
codecodecode
#include<cstdio> #include<algorithm> #include<cstring> #define ll long long using namespace std; ll n,num,flag,f,last,ok,read,no=1; char s[11000]; void add_num(ll x) {if(!x) putchar('0');if(x<0) printf("-1"),x=-x;ll w=1;while(w<=x)w*=10;w/=10;while(w)putchar(x/w+'0'),x%=w,w/=10;return; } int main() {freopen("equation.in","r",stdin);freopen("equation.out","w",stdout);scanf("%s",s+1);n=strlen(s+1);for(ll i=1;i<=n;i++){if(s[i]>='0'&&s[i]<='9')read=read*10ll+s[i]-'0';else{if(s[i]=='x') ok=1,num=max(read,1ll);if(s[i]=='+'||s[i]=='-'){if(ok){last=max(read,1ll);num*=last;last--;if(f) putchar('-');else if(flag) putchar('+');flag=1;if(num!=1ll||!last) add_num(num);if(last>0ll) putchar('x');if(last>1ll) putchar('^'),add_num(last); no=0;}num=last=ok=0ll;f=(s[i]=='-');}read=0;} }if(ok){last=max(read,1ll);num*=last;last--;if(f) putchar('-');else if(flag) putchar('+');flag=1ll;if(num!=1ll||!last) add_num(num);if(last>0ll) putchar('x');if(last>1ll) putchar('^'),add_num(last);no=0;}if(no) putchar('0'); }總結
以上是生活随笔為你收集整理的jzoj4803-[NOIP2016提高A组模拟9.28]求导【模拟】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电脑配置推荐2000左右(电脑配置推荐2
- 下一篇: jzoj4804-[NOIP2016提高