3237. n! 进制

zhouzhouzhou

反推n!进制,答案不唯一?比如十进制是10
120 13!+22!+0=10
50
42
都可以吧?

我太难了
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t;cin>>t;
    int p[11] = {0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800};
    for (int i = 0; i < t;i++){
        int s;
        cin >> s;
        printf("case #%d:\n", i);
        if(s==0){
            cout << 0 << endl;
            continue;
        }
        string sum;
        for (int j = 10;j>0;j--){
            sum += s / p[j] + '0';
            s %= p[j];
        }
        sum.erase(0, sum.find_first_not_of('0'));
        cout << sum << endl;
    }
    return 0;
}
10185101178

include

include

include

int n_cheng[11]={1,1,2,6,24,120,720,5040,40320,362880,3628800};
int main()
{
int t,z;
scanf(“%d”,&t);
for(z=0;z=1;i–)
{
u=n/n_cheng[i];
n=n-u*n_cheng[i];

        if(u!=0) flag=1;
        if(flag==1) printf("%d",u);
        else if(i==1&&u==0) printf("%d",u);

    }
    printf("\n");


}
return 0;

}

你当前正在回复 博客/题目
存在问题!