pku2402.cpp

来自「这是ACM 方面的资料 是PKU的 北京大学的出来的」· C++ 代码 · 共 48 行

CPP
48
字号
#include <stdio.h>

void out(__int64 t)
{
	__int64 i, tp, tp2;
	__int64 base = 18;
	tp = t;
	while (tp > base)
	{
		tp -= base;
		base *= 10;
	}
	base /= 2;
	if (tp > base)
	{
		tp2 = base / 9 + tp - base - 1;
		printf("%I64d", tp2);
		while (tp2 > 0)
		{
			printf("%d", tp2 % 10);
			tp2 /= 10;
		}
	}
	else
	{
		tp2 = base / 9 + tp - 1;
		printf("%I64d", tp2);
		tp2 /= 10;
		while (tp2 > 0)
		{
			printf("%d", tp2 % 10);
			tp2 /= 10;
		}
	}
	printf("\n");
}

int main()
{
	__int64 t, k, i, tmp;
	while (scanf("%I64d", &t) != -1 && t)
	{
		out(t);
	}
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?