diff --git a/1771_systemnumby/Readme.md b/1771_systemnumby/Readme.md new file mode 100644 index 0000000..b4f8d75 --- /dev/null +++ b/1771_systemnumby/Readme.md @@ -0,0 +1,3 @@ +# 标题 + +* 内容 \ No newline at end of file diff --git a/1771_systemnumby/doc/Readme.md b/1771_systemnumby/doc/Readme.md new file mode 100644 index 0000000..db2f8ca --- /dev/null +++ b/1771_systemnumby/doc/Readme.md @@ -0,0 +1,20 @@ +# R进制高精度乘法 + +题目描述 +  计算R(2<=R<=36)进制下两个高精度数的乘法,这两个数的位数均不超过100位,并输出结果(R进制,A=10,B=11,C=12,......,Z=35),输入输出中涉及到的英文字母均为大写格式字母。 + +输入输出格式 +输入格式: +  三行,第一行,R。第二、三行分别为用字符串表达的两个高精度数。 +输出格式: +  一行,结果值。 + +输入输出样例 +输入样例#1: +8 +3 +3 +输出样例#1: +11 +提示信息 +  直接以R进制进位进行运算。 \ No newline at end of file diff --git a/1771_systemnumby/main.cpp b/1771_systemnumby/main.cpp new file mode 100644 index 0000000..f39ad54 --- /dev/null +++ b/1771_systemnumby/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + std::cout << "Hello Easy C++ project!" << std::endl; +} diff --git a/1771_systemnumby/main.exe b/1771_systemnumby/main.exe new file mode 100644 index 0000000..fc4df42 Binary files /dev/null and b/1771_systemnumby/main.exe differ diff --git a/1771_systemnumby/systemnumby.cpp b/1771_systemnumby/systemnumby.cpp new file mode 100644 index 0000000..b850ada --- /dev/null +++ b/1771_systemnumby/systemnumby.cpp @@ -0,0 +1,43 @@ +#include +#include +using namespace std; +int main() +{ + int n, a[101] = { 0 }, b[101] = { 0 }, c[201] = { 0 }, lena, lenb, lenc = 0; + string a1, b1; + cin >> n >> a1 >> b1; + lena = a1.size(); + lenb = b1.size(); + for (int i = 0; i < lena; i++) { + if (a1[i] >= 'A') { + a1[i] = a1[i] - 'A' + '9' + 1; + } + a[lena-i-1] = a1[i] - '0'; + } + for (int i = 0; i < lenb; i++) { + if (b1[i] >= 'A') { + b1[i] = b1[i] - 'A' + '9' + 1; + } + b[lenb-1-i] = b1[i] - '0'; + } + for (int i = 0; i < lena; i++) { + for (int j = 0; j < lenb; j++) { + c[i + j] += a[i] * b[j]; + c[i + j + 1] += c[i + j] / n; + c[i + j] %= n; + } + } + int len = lena + lenb; + while(c[len-1]==0&&len>0){ + len--; + } + while (len > 0) { + --len; + if (c[len] > 9) { + char c1 = c[len] - 10 + 'A'; + cout << c1; + } else { + cout << c[len]; + } + } +} \ No newline at end of file diff --git a/1771_systemnumby/systemnumby.exe b/1771_systemnumby/systemnumby.exe new file mode 100644 index 0000000..731c32d Binary files /dev/null and b/1771_systemnumby/systemnumby.exe differ diff --git a/1771_systemnumby/test/in.txt b/1771_systemnumby/test/in.txt new file mode 100644 index 0000000..db69eab --- /dev/null +++ b/1771_systemnumby/test/in.txt @@ -0,0 +1,3 @@ +8 +3 +3 \ No newline at end of file diff --git a/1771_systemnumby/test/in2.txt b/1771_systemnumby/test/in2.txt new file mode 100644 index 0000000..30b7665 --- /dev/null +++ b/1771_systemnumby/test/in2.txt @@ -0,0 +1,3 @@ +16 +88 +88 \ No newline at end of file diff --git a/1771_systemnumby/test/in3.txt b/1771_systemnumby/test/in3.txt new file mode 100644 index 0000000..e7bbf11 --- /dev/null +++ b/1771_systemnumby/test/in3.txt @@ -0,0 +1,3 @@ +16 +A1A +B2B \ No newline at end of file diff --git a/1771_systemnumby/test/in4.txt b/1771_systemnumby/test/in4.txt new file mode 100644 index 0000000..aeccc59 --- /dev/null +++ b/1771_systemnumby/test/in4.txt @@ -0,0 +1,3 @@ +16 +2 +7 \ No newline at end of file diff --git a/1771_systemnumby/test/in5.txt b/1771_systemnumby/test/in5.txt new file mode 100644 index 0000000..703a54d --- /dev/null +++ b/1771_systemnumby/test/in5.txt @@ -0,0 +1,3 @@ +16 +1A +1A \ No newline at end of file diff --git a/1771_systemnumby/test/out.txt b/1771_systemnumby/test/out.txt new file mode 100644 index 0000000..2dc4eb6 --- /dev/null +++ b/1771_systemnumby/test/out.txt @@ -0,0 +1,30 @@ +## z:\Chao\src\1771_systemnumby\test\in.txt +2020/03/24 周二 13:43:26.46 +11 +----------------------------------------------- +Process exited after 160 ms with return value 0 + +## z:\Chao\src\1771_systemnumby\test\in2.txt +2020/03/24 周二 13:43:26.46 +4840 +----------------------------------------------- +Process exited after 90 ms with return value 0 + +## z:\Chao\src\1771_systemnumby\test\in3.txt +2020/03/24 周二 13:43:26.46 +70D05E +----------------------------------------------- +Process exited after 90 ms with return value 0 + +## z:\Chao\src\1771_systemnumby\test\in4.txt +2020/03/24 周二 13:43:26.46 +E +----------------------------------------------- +Process exited after 80 ms with return value 0 + +## z:\Chao\src\1771_systemnumby\test\in5.txt +2020/03/24 周二 13:43:26.46 +2A4 +----------------------------------------------- +Process exited after 80 ms with return value 0 +