Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created June 2, 2021 01:51
Show Gist options
  • Save sakapon/18b9cfaee864294c0d33ff51d4bde8c1 to your computer and use it in GitHub Desktop.
Save sakapon/18b9cfaee864294c0d33ff51d4bde8c1 to your computer and use it in GitHub Desktop.
競プロ典型 90 問 / Q030
using System;
using System.Linq;
class Q030
{
static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
static void Main()
{
var (n, k) = Read2();
Console.WriteLine(GetPrimeTypes(n).Count(x => x >= k));
}
static int[] GetPrimeTypes(int n)
{
var c = new int[n + 1];
for (int p = 2; p <= n; ++p)
if (c[p] == 0)
for (int x = p; x <= n; x += p)
++c[x];
return c;
}
}
@sakapon
Copy link
Author

sakapon commented Jun 2, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment