hdu1753 看着简单写着蛋疼的题挺好的

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
#define N 111111
struct  _edge
{
    int v;
    _edge *next;
};
_edge *head[N],*cur;
inline void add(int u,int v)
{
    cur=new _edge;
    cur->v=v;
    cur->next=head[u];
    head[u]=cur;
}
char a[1000],b[1000];
int res[1000],y;
int main()
{
   while(scanf("%s%s",a,b)==2)
   {
       y=0;
       res[0]=0;
       int id1,id2;
        for(id1=0;a[id1]!='.'&&a[id1]!='\0';++id1);
        for(id2=0;b[id2]!='.'&&b[id2]!='\0';++id2);
        int len1=strlen(a)-id1-(a[id1]=='.'),len2=strlen(b)-id2-(b[id2]=='.'),z1=strlen(a),z2=strlen(b);
        int len3=Max(len1,len2);
        for(int i=id1;i<id1+len3;++i)
        if(i<z1-1) a[i]=a[i+1];
        else a[i]='0';
         for(int i=id2;i<id2+len3;++i)
        if(i<z2-1) b[i]=b[i+1];
        else b[i]='0';
//        cout<<a<<"\n"<<b<<"\n";
        int i=id1+len3-1,j=id2+len3-1;
        while(i>=0||j>=0)
        {
            int t1,t2,t3;
            if(i<0) t1=0;
            else  t1=a[i]-'0';
            if(j<0) t2=0;
            else t2=b[j]-'0';
            t3=t1+t2+res[y];
            res[y]=t3%10;
            res[++y]=t3/=10;
            --i,--j;
        }
        int st=0;
        while(res[st]==0&&st<len3) ++st;
        while(res[y]==0&&y>len3) --y;
        ffd(k,y,len3)
        putchar('0'+res[k]);
     if(st<len3) putchar('.');
        ffd(k,len3-1,st)
        putchar('0'+res[k]);
        puts("");
   }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值