0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

今日の問題

↑押してください。

自分の回答(javascript)

function Main(input){
    min = 1e18
    max = -1e18
    let abc = "abcdefghijklmnopqrstuvwxyz".split("")
    let ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
    let f = 0
    if(f == 0){
      input = parseInt(input.trim())
    }
    if(f == 1){
      input = input.trim().split("\n").map((a)=>parseInt(a))
    }
    if(f == 2){
      input = input.trim().split("\n").map((a)=>a.split(" ").map((b)=>parseInt(b)))
    }
   n = input
   let primelist = make_primelist(1000000)
   function make_primelist(aa){
  let yakusu = new Array(aa)
  for(let i = 0;i<aa;i++){
    yakusu[i] = new Array()
  }
  let primelist = []
   for(let i = 2;i<aa;i++){
     if(yakusu[i].length == 0){
       primelist.push(i)
       for(let j = i;j<aa;j += i){
         yakusu[j].push(i)
         
       }
     }
   }
   return primelist
}

//console.log(primelist)
   let count = 0
   for(let i = 0;i<2000;i++){
     for(let j = i+1;(primelist[i]*primelist[j])**2<=n;j++){
        count ++
     }
   }
   for(let i = 0;i<100;i++){
     if(primelist[i] ** 8<= n){
     count ++
     }
   }
   function primeNumber(n) {
 if (n === 2) return true;
 for (let i = 2; i < n; i++) {
   if (n % i === 0) return false;
 }
 return true;
}
   function getGCD(a, b){
        while (a > 0 && b > 0)
        {
            if (a < b)
                b %= a;
            else
                a %= b;
        }
        return Math.max(a, b);
    }
   console.log(count)
   
  }
  Main(require("fs").readFileSync(0, "utf8"));
  
//ここより上は定型文です。

工夫した点

まず約数の個数とは素因数分解したときの肩の数に一を足した数をすべて掛け合わせる事によって得ることができます。よって9個ということ9か(2+1)(2+1)です。よってn^8またはn^2m^2ということになります。このときn,mは素数です。(素因数分解なんだから当たり前)あとはこれを全探索します。10^12までなのでBigIntを使わなくても大丈夫です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?