7-1 Forever (20 分) "Forever number" is a positive integer A with K digits, satisfying the following constrains: the sum of all the digits of A is m; the sum of all the digits of A+1 is n; and the greatest common divisor of m and n is a prime num…
Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebration, the alumni association (校友会) has gathered the ID’s of all her alumni. Now your job is to write a program to count the number of alumni among all…
7-4 Dijkstra Sequence (30 分) Dijkstra's algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from one particular source vertex to all the other vertices o…
7-3 Postfix Expression (25 分) Given a syntax tree (binary), you are supposed to output the corresponding postfix expression, with parentheses reflecting the precedences of the operators. Input Specification Each input file contains one test case. For…
7-2 Merging Linked Lists (25 分) Given two singly linked lists L 1 =a 1 →a 2 →...→a n−1 →a n  L1=a1→a2→...→an−1→an and L 2 =b 1 →b 2 →...→b m−1 →b m  L2=b1→b2→...→bm−1→bm . If n≥2m n≥2m , you are supposed to reverse and merge the shorter one into the…
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, a binary tree can be uniquely determined. Now given a sequence of statements about the structure of the resulting tree, yo…
Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone c…
Sexy primes are pairs of primes of the form (p, p+6), so-named since “sex” is the Latin word for “six”. (Quoted from http://mathworld.wolfram.com/SexyPrimes.html) Now given an integer, you are supposed to tell if it is a sexy prime. Input Specificati…
A Good In C纯模拟题,用string数组读入数据,注意单词数量的判断 #include<bits/stdc++.h> using namespace std; ; ][]; int main () { ;i<=;i++) { ;j<=;j++) cin>>a[i][j]; } string t; getchar (); getline (cin,t); ]; ; ;i<t.length();i++) { if (t[i]>='A'&&…
题意: 输入一个正整数N(<=10000),接着依次输入N个学生的ID.输入一个正整数Q,接着询问Q次,每次输入一个学生的ID,如果这个学生的ID不出现在之前的排行榜上输出Are you kidding,否则如果已经询问过输出Checked,否则如果这位学生排名第一输出Mystery Award,否则如果这位学生的排名是质数输出Minion,否则输出Chocolate. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/…