一个月没有写博客了。

其实我知道这个博客没有人看,所以更多的是写给自己看,有的时候会觉得自己有点孤僻,不太好,可转念想一想,做自己就好,人嘛,最重要的是开心。所以这个博客,某种意义上是我的精神寄托,一个孤寂的、喜欢和机器打交道的人的精神避风港。

话说博客使用的评论系统就要过期了,也罢,反正是没有人评论的。真正在意我的人,自有联系到我的办法。

在学校里一直过得匆匆忙忙,似乎从来没有时间沉下心来。仔细想想,进入大学这一年,特别是这一学期,好像经历的比过去加起来都多。以前的我,太咄咄逼人,思想不够成熟。

没有人是一座孤岛。不成熟的我,曾经给许多人的生活造成了困扰,也伤害了很多人。在此,我为我曾经的愚蠢、自大、傲慢、幼稚道歉。对不起,我给大家添麻烦了。

夏天来了。

最近做的都是英文题,正好顺手测试一下各翻译网站的翻译能力。

原文

Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the stalls in the new barn are different. For the first week, Farmer John randomly assigned cows to stalls, but it quickly became clear that any given cow was only willing to produce milk in certain stalls. For the last week, Farmer John has been collecting data on which cows are willing to produce milk in which stalls. A stall may be only assigned to one cow, and, of course, a cow may be only assigned to one stall.
Given the preferences of the cows, compute the maximum number of milk-producing assignments of cows to stalls that is possible.

The input includes several cases. For each case, the first line contains two integers, N (0 <= N <= 200) and M (0 <= M <= 200). N is the number of cows that Farmer John has and M is the number of stalls in the new barn. Each of the following N lines corresponds to a single cow. The first integer (Si) on the line is the number of stalls that the cow is willing to produce milk in (0 <= Si <= M). The subsequent Si integers on that line are the stalls in which that cow is willing to produce milk. The stall numbers will be integers in the range (1..M), and no stall will be listed twice for a given cow.

For each case, output a single line with a single integer, the maximum number of milk-producing stall assignments that can be made.


- 阅读剩余部分 -

2017-04-16更新:

void init_prime(int n) //欧拉素数筛法
{
    for(int i = 2; i <= n; i++)
    {
        if(!prime[i])
            prime[++prime[0]] = i;
        for(int j = 1; j <= prime[0] && prime[j] <= n / i; j++)
        {
            prime[prime[j] * i] = 1;
            if(i % prime[j] == 0)
                break;
        }
    }
}

以下是原文

- 阅读剩余部分 -

快速幂:a的b次方对n取余

int ksm(int a, int b, int n)
{
    a %= n;
    int ans = 1;
    while(b)
    {
        if(b%2 == 1)
            ans = ans*a%n;
        b /= 2;
        a = a*a%n;
    }
    return ans;
}