小编Isa*_*iev的帖子

找到一个具有正好N个除数的最小数字

假设我们有一些除数N.我想找到一个minimum number具有N个除数的除数.

我的算法

  • 我找到了素数(pm = [2,3,5,7,..])
  • 我找到了N的素因子(N = 12,p = [2,2,3],反转p rp = [3,2,2])
  • number*= pm[i]^(rp[i]-1),i = 1 ...素数因子的长度

对于N = 12,答案是 60 = 2^(3-1) * 3^(2-1) * 5^(2-1)

但是对于数字243,我的算法给出了错误的答案(5336100 - 但它不是具有243个除数的最小数).预期的数字是2822400.

我的错在哪里?有文献吗?

algorithm math

4
推荐指数
1
解决办法
955
查看次数

如何在 Spring-Boot 中注入静态类?

这个问题被问了很多次。我有点困惑,希望你的想法。

我正在 Spring-Boot 中集成 Google Cloud Storage。

我有配置类。

@Component
@ConfigurationProperties(prefix = "gcs.credentials")
public class  GCSConfig {

    private String serviceAccountId;

    //...
}
Run Code Online (Sandbox Code Playgroud)

实现单例模式的存储工厂。

@Component
public class StorageFactory {

    @Autowired
    private static GCSConfig gcsConfig;

    private static Storage instance = null;

    public static synchronized Storage getService() throws GeneralSecurityException, IOException {
        if (instance == null) {
            instance = buildService();
        }
        return instance;
    }

    private static Storage buildService() throws GeneralSecurityException, IOException {

        HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
        JsonFactory jsonFactory = new JacksonFactory();
        // ...
        // I …
Run Code Online (Sandbox Code Playgroud)

java spring google-cloud-storage spring-boot

-1
推荐指数
1
解决办法
1万
查看次数