【牛客算法周练】A
相反数
http://www.nowcoder.com/questionTerminal/1f9497cd513f4a578412bc51e3c39bc7
这个题数据范围太小,甚至不需要用手写的大数加法。
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> #include<vector> #include<stack> #include<map> #include<set> #include<queue> #include<iomanip> #include<string> #include<ctime> #include<list> #include<bitset> #define pb push_back #define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0) #define local freopen("in.text","r",stdin) #define pi acos(-1) typedef long long ll; using namespace std; template<class T> bool read(T & ret)//ll,int,double,float,+/- { char c;int sgn;T bit=0.1;if(c=getchar(),c==EOF) return 0;while(c!='-' && c!='.' && (c<'0' || c>'9')) c=getchar();sgn=(c=='-')?-1:1;ret=(c=='-')?0:(c-'0');while(c=getchar(),c>='0' && c<='9') ret=ret*10+(c-'0');if(c==' '||c=='\n') {ret*=sgn;return 1;}while(c=getchar(),c>='0' && c<='9') ret+=(c-'0')*bit,bit/=10;ret*=sgn;return 1; } signed main(){ int n; cin>>n; int nn=n; vector<int> num; while(nn) { num.pb(nn%10); nn/=10; } int ans=0; for(auto x:num) ans=ans*10+x; cout<<ans+n<<endl; return 0; }