int main() { int t; while(~scanf("%d", &n)) { memset(cnt, 0, sizeof(cnt)); for(int i = 0; i < n; ++i) scanf("%d", &t), ++cnt[t]; //记录每个时刻出现多少公交
m = 0;//生成以时刻i为首班 两班间隔时间为j的所有满足的公交线路 for(int i = 0; i < 30; ++i) for(int j = i + 1; j < 60 - i; ++j) if(ok(i, j)) r[m++] = route(i, j, 1 + (59 - i) / j);
sort(r, r + m); ans = 17; dfs(0, 0, 0); printf("%d\n", ans); } return0; }
The Buses
Description A man arrives at a bus stop at 12:00. He remains there during 12:00-12:59. The bus stop is used by a number of bus routes. The man notes the times of arriving buses. The times when buses arrive are given.
Find the schedule with the fewest number of bus routes that must stop at the bus stop to satisfy the input data. For each bus route, output the starting time and the interval.
Input
Your program is to read from standard input. The input contains a number n (n <= 300) telling how many arriving buses have been noted, followed by the arrival times in ascending order.
Output
Your program is to write to standard output. The output contains one integer, which is the fewest number of bus routes.