1896. 公牛数学

news/2024/10/17 16:23:09/

题目描述

公牛在数学方面比奶牛强很多,他们自称可以计算很大的整数之间的乘法,并得到精确的结果。农夫约翰想知道他们的答案是否正确。请你帮助他检查公牛的答案。读入2个正整数(不大于10^40),计算他们的乘积,输出一个自然数(不能含有多余的零)。

约翰农夫让你自己做这个工作。

输入

第1…2行:每行包含一个十进制数

输出

第1行:输出两个数乘积

Code

#pragma GCC optimize(3)
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int Maxn = 100510;
struct fantastic {int len, s[Maxn];fantastic(){memset( s, 0, sizeof(s) );len = 1;}fantastic( int num ){*this = num;}fantastic( const char* num ){*this = num;}fantastic operator =( int num ){char s[Maxn];sprintf( s, "%d", num );*this = s;return(*this);}string str() const{string res = "";for ( int i = 0; i < len; i++ )res = (char) (s[i] + '0') + res;if ( res == "" )res = "0";return(res);}void clean(){while ( len > 1 && !s[len - 1] )len--;}fantastic operator =( const char * num ){len = strlen( num );for ( int i = 0; i < len; i++ )s[i] = num[len - i - 1] - '0';return(*this);}fantastic operator +( const fantastic &b ) const{fantastic c;c.len = 0;for ( int i = 0, g = 0; g || i < max( len, b.len ); i++ ){int x = g;if ( i < len )x += s[i];if ( i < b.len )x += b.s[i];c.s[c.len++]	= x % 10;g		= x / 10;}return(c);}fantastic operator *( const fantastic &b ){fantastic c;c.len = len + b.len;for ( int i = 0; i < len; i++ )for ( int j = 0; j < b.len; j++ )c.s[i + j] += s[i] * b.s[j];for ( int i = 0; i < c.len - 1; i++ ){c.s[i + 1]	+= c.s[i] / 10;c.s[i]		%= 10;}c.clean();return(c);}fantastic operator -( const fantastic &b ){fantastic c;c.len = 0;for ( int i = 0, g = 0; i < len; i++ ){int x = s[i] - g;if ( i < b.len )x -= b.s[i];if ( x >= 0 )g = 0;else {g	= 1;x	+= 10;}c.s[c.len++] = x;}c.clean();return(c);}bool operator <( const fantastic &b ) const{if ( len != b.len )return(len < b.len);for ( int i = len - 1; i >= 0; i-- )if ( s[i] != b.s[i] )return(s[i] < b.s[i]);return(false);}bool operator >( const fantastic &b ) const{return(b < *this);}bool operator <=( const fantastic &b ){return(!(b > *this) );}bool operator ==( const fantastic &b ){return(!(b < *this) && !(*this < b) );}fantastic operator +=( const fantastic &b ){*this = *this + b;return(*this);}
};
istream & operator >>( istream & in, fantastic & x )
{string s;in >> s;x = s.c_str();return(in);
}ostream & operator <<( ostream & out, const fantastic &x )
{out << x.str();return(out);
}int main()
{freopen( "bullmath.in", "r", stdin);freopen( "bullmath.out", "w", stdout);fantastic a, b;cin >> a >> b;cout << a * b;return 0;
}

http://www.ppmy.cn/news/206068.html

相关文章

oppo手机android 版本号,oppo手机怎么升级到安卓11

oppo手机怎么升级到安卓11&#xff1f;在最近&#xff0c;谷歌发布了Android 11系统&#xff0c;国内很多品牌的手机也可以陆续可以升级到安卓11系统&#xff0c;那oppo手机怎么升级为安卓11系统呢&#xff0c;在哪里升级到安卓11&#xff0c;下面就和小编一起来看看吧&#xf…

oppor15android10怎么降级,OPPOR15系统降级教程

www.netded.com发表时间: 2018-11-05 10:45 也过来说说咱们的这个OPPO R15手机的系统降级操作了&#xff0c;也就是大家常说的回退操作了&#xff0c;因为有的机友感觉系统升级之后并不是特别满意&#xff0c;所以想进行系统回退操作&#xff0c;想回退到原来的旧版本的系统&am…

oracle+m10-5,pchm10是oppo什么型号

pchm10是oppo a11手机的型号。外观方面&#xff0c;oppo a11搭载6.5英寸的浅水滴阳光屏&#xff0c;拥有暮晨紫&#xff0c;极夜黑&#xff0c;流云白&#xff0c;湖光绿&#xff0c;香草薄荷5种配色。配置方面&#xff0c;oppo a11搭载骁龙665处理器&#xff0c;搭配5000mAh电…

android 判断oppo手机型号,oppo android 11支持什么型号

oppo android 11支持什么型号&#xff1f;在最近&#xff0c;谷歌和OPPO手机相继推出Android 11安卓系统版本&#xff0c;那OPPO手机哪些型号可以更新Android 11呢&#xff0c;oppo android 11支持什么型号&#xff0c;下面就和小编一起来看看吧&#xff01; Find X2系列可更新…

oppoa9处理器怎么样_oppoa9什么处理器 配置功能评测处理器型号是这个

oppoa9目前还处于预售阶段&#xff0c;是oppo手机继opporeno旗舰机发布之后&#xff0c;发布的一款中端机&#xff0c;关于oppoa9这款手机&#xff0c;大家对于新机的性能也是比较关注的&#xff0c;要想了解oppoa9的性能&#xff0c;还是要看新机的处理器。 在处理器方面&…

mac下adb找不到OPPO r11

背景 入职后&#xff0c;单位给我的测试手机是OPPO r11。结果手机连上mac电脑后&#xff0c;不管是Android Studio4.2还是adb&#xff0c;都找不到测试机。经过一番尝试&#xff0c;发现oppo需要特殊处理&#xff0c;详情参见本文内容 激活oppo r11 如果用的oppo r11是第一次…

oppo9s刷机教程_OPPOR9S刷机包

详情 OPPOR9S刷机包是专为OPPO手机刷机而推出的一款辅助工具&#xff0c;这款工具功能非常的强大&#xff0c;满足你的日常所需要解决的问题&#xff0c;OPPOR9S刷机包操作简单&#xff0c;几乎不需要太过复杂的操作只需照着点击即可&#xff0c;让您能够轻松上手&#xff0c;喜…

oppo怎么广告接入_oppo信息流广告投放操作指南

OPPO广告投放后台地址:https://e.oppomobile.com/ OPPO信息流广告投放操作指南 一、新建推广 路径:推广 - 信息流推广 - 新建广告 1. 推广名称:设置单个广告的推广名称。 2. 推广计划:单个推广计划包含若干个推广。 2.1 推广计划名称:单个推广计划的名称。 2.2 日…