游客 Signup | Login
中文 | En

2530 - 【数组】素数竖式(vertical)

下面的竖式是乘法运算:

                               PPPP

                            X     P

                        ——————

                             PPPPP


式中P表示为一位的素数(2、3、5、7),式中所有的P表示的数可能不相同,编程输出此乘法竖式的所有可能方案。


Input

无输入。

Output

PPPP*P=PPPPP格式输出,每种方案一行,按PPPP从小到大输出。

Examples

Input


                

Output


                

Hint

提示:P表示的一位素数2357用数组来循环

Solution C++

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int i,j,k,l,m,n,p,f,t;
	int a[4]={2,3,5,7};
	for (i=0;i<4;++i)
		for (j=0;j<4;j=j+1)
			for (k=0;k<4;k++)
				for (l=0;l<4;l=l+1)
					for (m=0;m<4;++m)
					{
						n=a[i]*1000+a[j]*100+a[k]*10+a[l];
						p=n*a[m];
						if (p>10000&&p<100000) {
							f=1;
							do {
								t=p %10;
								p=p / 10;
								if (t!=2&&t!=3&&t!=5&&t!=7) f=0;}
							while (p>0);
						    if (f==1)  cout<<n<<'*'<<a[m]<<'='<<n*a[m]<<endl;
						}
					}
	return 0;    
}

Hint

提示:P表示的一位素数2357用数组来循环

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题