跳到正文

科技·工程

不正经系列#2 Number Divider using 114514 恶臭数字制造器

sky_of_stars约 3 分钟
原文
文章信息与版本

文章信息

发布
2025年6月13日
收录
2026年4月10日
更新
2026年11月9日
篇幅
约 3 分钟

版本

  1. v2当前
  2. v1

INTRODUCTION

The GREAT STUPID inventor @sky_of_stars has once seen a website that can translate numbers into sums and other caculations of parts from the number 114514.@sky_of_stars found that intereting,so he soon made another version of it,doing bascily the website does.However,he forgot the website’s name,so he decided to publish his boring code here.

TRANSLATION 翻译

恶臭数字制造机:把数字拆分成由114514的一部分(如1145,114,514,11,45,14等等)组成的表达式。


CODE

C++
#include <bits/stdc++.h>

using namespace std;
unsigned long long a[15]={0,4,5,11,14,45,114,514,1145,114514};
void f(unsigned long long x){
	if(x==1){
		cout << 1;
		return;
	}
	if(x==2){
		cout << "5-4+1";
		return;
	}
	if(x==3){
		cout << "11-4-4";
	}
	for(int i=9;i>=1;i--){
		if(a[i]<=x){
			int td=x/a[i],tm=x%a[i];
			if(a[i]==x){
				cout << a[i];
				return ;
			}
			if(td>1){
				bool flag=0;
				int tx;
				for(int j=9;j>=1;j--){
					if(a[j]==td){
						tx=j;
						flag=1;
						break;
					}
				}
				if(!flag)cout << "(";
				if(!flag)f(td);
				else cout << a[tx];
				if(!flag)cout << ")";
				cout << "*";
			}
			cout << a[i];
			if(tm>1){
				cout << "+";
				bool flag=0;
				int tx;
				for(int j=9;j>=1;j--){
					if(a[j]==tm){
						tx=j;
						flag=1;
						break;
					}
				}
				if(!flag)cout << "(";
				if(!flag)f(tm);
				else cout << a[tx];
				if(!flag)cout << ")";
			}else if(tm==1){
				cout << "+1";
			}
			break;
		}
	}

}
int main() {
	srand(time(0));
	unsigned long long a;
	while(1){
		cin >> a;
		f(a);
		cout << endl;
	}
	return 0;
}
原文
抓取于
  1. sky_of_stars

    18446744073709551615