2020-12-07 光棍数

发布于:2024-12-18 ⋅ 阅读:(50) ⋅ 点赞:(0)

由光棍数的特征可推导其商的个位数不存在偶数且只有1、3、7、9这4个数。一个数可匹配多个光棍数且必定是中间隔着0的循环数。 

void 光棍数(int n)
{//缘由http://ask.csdn.net/questions/3444069 做乘法运行时间超长
	int w = 0; long long x = 111111111111111, j = 0;
	//j = x*n;
	//while (j)if (j % 10 != 1) j = ++x*n, w = 0, system("CLS"), cout << x; else j /= 10, ++w;
	//cout << (j = x * n) <<< ends << n << ends << x << ends << w << endl;
	j = x / n;
	while (x && j * n != x)x /= 10, j = x / n, cout << x << endl;
	j = x; while (j)++w, j /= 10;
	if(x)cout << (j = x / n) << ends << n << ends << x << ends << w << endl;
}



	int aa = 3;
	while (aa < 200)if (aa % 10 != 5)光棍数(aa), aa += 2; else aa += 2;

void 光棍数(int n)
{//缘由http://ask.csdn.net/questions/3444069 做乘法运行时间超长
	int w = 0; long long x = 1111111111111111111, j = 0;
	//j = x*n;
	//while (j)if (j % 10 != 1) j = ++x*n, w = 0, system("CLS"), cout << x; else j /= 10, ++w;
	//cout << (j = x * n) <<< ends << n << ends << x << ends << w << endl;
	j = x / n;
	while (x && j * n != x)x /= 10, j = x / n, ++w, cout << x << endl;
	//j = x; while (j)++w, j /= 10;
	cout << (j = x / n) << ends << n << ends << x << ends << (19-w) << endl;
}

void 光棍数(int n)
{//缘由http://ask.csdn.net/questions/3444069 做乘法运行时间超长
	int w = 0; long long x = 1111111111111111111, j = 0;
	//j = x*n;
	//while (j)if (j % 10 != 1) j = ++x*n, w = 0, system("CLS"), cout << x; else j /= 10, ++w;
	//cout << (j = x * n) <<< ends << n << ends << x << ends << w << endl;
	j = x / n;
	//while (x && j * n != x)x /= 10, j = x / n, ++w;//, cout << x << endl
	//j = x; while (j)++w, j /= 10;
	//if(x)cout << (j = x / n) << ends << n << ends << x << ends << (19-w) << endl;
	while (x)if (j * n != x && j % 1000 != 111)x /= 10, j = x / n, ++w; else cout << (j = x / n) << ends << n << ends << x << ends << (19 - w) << endl, x /= 10, j = x / n, ++w;
}



	int aa = 1;
	while (aa < 10000)if ((aa += 2) % 10 != 5)光棍数(aa);

 

 

  


网站公告

今日签到

点亮在社区的每一天
去签到