http://codevs.cn/problem/3115/

板子题~

// <H.cpp> - Sun Oct  9 12:58:23 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define MOD 1000000007
#define INF 1e9
#define IN inline
#define RG register
using namespace std;
typedef long long LL;
typedef long double LB;
const int MAXN=;
const int MAXM=;
inline int max(int &x,int &y) {return x>y?x:y;}
inline int min(int &x,int &y) {return x<y?x:y;}
inline LL gi() {
register LL w=,q=;register char ch=getchar();
while((ch<''||ch>'')&&ch!='-')ch=getchar();
if(ch=='-')q=,ch=getchar();
while(ch>=''&&ch<='')w=w*+ch-'',ch=getchar();
return q?-w:w;
}
const int _bod_=;
struct BN{
static const int N=;int a[N];char s[N];
int& operator [](int n){return a[n];}
bool operator <(BN b) const{
if(a[]<b[])return ;
if(a[]>b[])return ;
for(int i=a[];i>=;i--){
if(a[i]>b[i])return ;
if(a[i]<b[i])return ;
}
return ;
}
BN operator -(BN b) const{
BN ans=*this;int q=;
if(ans<b)swap(ans,b),q=-;
for(int i=;i<=ans[];i++){
ans[i]=ans[i]-b[i];
if(ans[i]<){ans[i+]--;ans[i]+=_bod_;}
}
while(ans[]&&!ans[ans[]])ans[]--;
for(int i=;i<=ans[];i++)ans[i]*=q;
return ans;
}
void read(){
scanf("%s",s);a[]=strlen(s);
for(int i=;i<=a[];i++)a[i]=s[a[]-i]-'';
}
void pri(){printf("%d",a[a[]]);for(int i=a[]-;i>=;i--)printf("%.1d",a[i]);}
}a,b;
int main()
{
freopen("3115.in","r",stdin);
freopen("3115.out","w",stdout);
a.read(),b.read();
if(a<b)printf("-"),(b-a).pri();else (a-b).pri();
return ;
}
05-11 14:00