import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
List<List<Short>> map = new ArrayList<>();
for (int i = 0; i <= n; i++) {
map.add(new ArrayList<>());
}
int[] in = new int[n + 1];
int[] out = new int[n + 1];
for (int i = 1; i <= m; i++) {
short a = sc.nextShort(), b = sc.nextShort();
map.get(a).add(b);
in[b]++;
out[a]++;
}
Queue<Short> queue = new LinkedList<>();
int[] path = new int[n + 1];
for (short i = 1; i <= n; i++) {
if (in[i] == 0) {
path[i] = 1;
queue.add(i);
}
}
int ans = 0;
while (!queue.isEmpty()) {
int a = queue.poll();
for(short i : map.get(a)) {
if (i == 0)
continue;
path[i] += path[a];
path[i] %= 80112002;
in[i]--;
out[a]--;
if (in[i] == 0) {
if (out[i] == 0) {
ans += path[i];
ans %= 80112002;
}
queue.add(i);
}
}
}
System.out.println(ans);
}
}
一、题目二、CODEimport java.util.*;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), m = sc.nextInt(); List<List<Short>> map = new ArrayList&.