多项式滚出OI【模拟】

>Link

luogu T202675


>Description

把数 f ( m ) f(m) f(m) 转化成 m m m 进制数
m , f ( m ) ≤ 1 0 18 m,f(m)\le10^{18} m,f(m)1018


>解题思路

实际上就是个大水题QwQ,但是不知道为啥有一个点RE了然后才60分
后来看了下别人的代码修改了一下存答案的方式就A了


>代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
#define N 10000010
using namespace std;

int n;
LL m, f, a, ans[N];

int main()
{
    
    
	scanf ("%lld%lld", &m, &f);
	while (f)
	{
    
    
		ans[++n] = f % m;
		f /= m;
	}
	printf ("%d\n", n);
	for (int i = 1; i <= n; i++)
	  printf ("%lld ", ans[i]);
	return 0;
}

おすすめ

転載: blog.csdn.net/qq_43010386/article/details/121093821