Topic description
Kirai likes to send "233" when chatting. "233" comes from Maopu emoji No. 233, which is a thumping and laughing emoji.
Kirai always replies "2333..." whenever she sees interesting news.
Kirai is actually very cold, he found this problem. In order not to want others to know that he was laughing immediately, he decided to multiply the two "233.." together and send it out.
Enter description:
There are multiple groups of input samples, all of which are positive integers. First, enter the number of sample groups T (T≤1500). Next, enter the number of T groups, each group of numbers consists of two 233 strings, each 233 string length 3≤n≤50. The data guarantees that each 233 string must have a 2 as the beginning, and the number of 3 is ≥ 2.
Output description:
The product of two 233 strings.
Example 1
enter
2 233 233 23333333333333333333333333333333333333333333333333 23333333333333333333333333333333333333333333333333
output
54289 544444444444444444444444444444444444444444444444428888888888888888888888888888888888888888888888889
Idea: Multiplication of large numbers, the multiplication of two numbers with the same format must have rules, right, so we can also find rules. . .
Large numbers are best written in java:
import java.io. *; import java.util. *; import java.math.*; public class Main { public static void main(String [] args) { BigInteger a,b,c; int n; Scanner cin = new Scanner(System.in); n = cin.nextInt(); for(int i=0;i<n;i++) { a = cin.nextBigInteger(); b = cin.nextBigInteger(); c = a.multiply(b); System.out.println(c); } } }
规律代码:
#include <bits/stdc++.h> using namespace std; int main() { int t; char a[55],b[55]; scanf("%d",&t); getchar(); while(t--) { scanf("%s%s",a,b); int la = strlen(a) - 1,lb = strlen(b) - 1; if(la == lb) { printf("5"); for(int i = 0; i < la - 1; i++) printf("4"); printf("2"); for(int i = 0; i < la - 1; i++) printf("8"); printf("9\n"); } else { if(la > lb) swap(la,lb); printf("5"); for(int i = 0; i < la - 1; i++) printf("4"); printf("3"); for(int i = 0; i < lb - la - 1; i++) printf("6"); printf("5"); for(int i = 0; i < la - 1; i++) printf("8"); printf("9\n"); } } return 0; }