PAT/轻便模拟练习集(2)

发布时间:2019-05-02  栏目:Python  评论:0 Comments

B100一.害死人不偿命的(三n+一)估量(一五)

以与输入一样的格式输出导数多项式非零项的周到和指数。数字间以空格分隔,但最后不能够有结余空格。注意“零多项式”的指数和周详都以0,可是代表为“0
0”。

各种输入包涵八个测试用例,第一行输入N
(
一<=N<=十0)、M(M>=0);第2行输入N个整数,之间用空格分隔。

Sample
Output:

Sample
Output:

 

Output:

Description:

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     //freopen("E:\\Temp\\input.txt", "r", stdin);
 6 
 7     int Da, Db;
 8     long long pA = 0, pB = 0, A, B;
 9     scanf("%lld %d %lld %d", &A, &Da, &B, &Db);
10 
11     while(A != 0) {
12         if(A%10 == Da) {
13             pA = pA*10+Da;
14         }
15         A /= 10;
16     }
17     while(B != 0) {
18         if(B%10 == Db) {
19             pB = pB*10+Db;
20         }
21         B /= 10;
22     }
23 
24     printf("%lld\n", pA+pB);
25 
26     return 0;
27 }

Sample
Input:

Sample
Output2:

Description:

输入在第二行提交不当先十5的正整数N,即参加比赛人数。随后N行,每行给出一高丽参赛者的新闻和实际业绩,包罗其所表示的该校的编号(从一方始接连编号)、及其比赛成绩(百分制),中间以空格分隔。

3 4 -5
2 6 1 -2 0

3862767
6 13530293 3

现给出四个人的比赛记录,请总计两方的胜、平、负次数,并且付诸双方分别出怎么样手势的胜算最大。

13 1 2
3 4 5 6 7 8 9 10 20 16 18

For
each test case you should output the product of A and B in one line,
with the same format as the input. Notice that there must be NO extra
space at the end of each line. Please be accurate up to 1 decimal
place.

要博取四个C语言程序的周转时刻,常用的形式是调用头文件time.h,在那之中提供了clock()函数,能够捕捉从程序开端运维到clock()被调用时所费用的时刻。那几个小时单位是clock
tick,即“石英钟照管”。同时还有一个常数CLK_TCK,给出了机器机械钟每秒所走的石英表料理数。于是为了拿走二个函数f的运维时刻,大家假如在调用f在此之前先调用clock(),获得一个挂钟照管数C1;在f执行到位后再调用clock(),得到另1个挂钟照顾数C2;四遍得到的石英钟照望数之差(C二-C1)正是f运营所费用的电子手表照顾数,再除以常数CLK_TCK,就获得了以秒为单位的运作时刻。

Given
three integers A, B and C in [-263, 263], you
are supposed to tell whether A+B > C.

Sample
Input:

Sample
Output:

Sample
Output2:

3 3
3.6 2 6.0 1 1.6

Input:

世家应该都会玩“锤子剪刀布”的玩耍:多个人还要提交手势,胜负规则如图所示:

Sample
Input1:

输出第1、贰行分别给出甲、乙的胜、平、负次数,数字间以3个空格分隔。第1行提交四个字母,分别代表甲、乙获胜次数最多的手势,中间有3个空格。如果解不唯一,则输出按字母序最小的解。

Sample
Input:

Each
input file contains one test case. For each case, the first line
contains a positive integer K (<= 20) which is the number of repeat
times. Then the next line contains the given order. All the numbers in a
line are separated by a space.

N 11 2
N 9

S7 C11
C10 C12 S1 H7 H8 H9 D8 D9 S11 S12 S13 D10 D11 D12 S3 S4 S6 S10 H1 H2 C13
D2 D3 D4 H6 H3 D13 J1 J2 C1 C2 C3 C4 D1 S5 H5 H11 H12 C6 C7 C8 C9 S2 S8
S9 H10 D5 D6 D7 H4 H13 C5

出口从n总结到一内需的步数。

A1042.
Shuffling Machine (20)

 

Each
input file contains one test case. For each case, the first line
contains an integer N (in [3, 105]), followed by N integer
distances D1 D2 … DN, where
Di is the distance between the i-th and the (i+1)-st exits,
and DN is between the N-th and the 1st exits. All the numbers
in a line are separated by a space. The second line gives a positive
integer M (<=104), with M lines follow, each contains a
pair of exit numbers, provided that the exits are numbered from 1 to N.
It is guaranteed that the total round trip distance is no more than
107.

Input:

 1 #include <cstdio>
 2 
 3 #define MaxSize 2010
 4 double List1[MaxSize], List2[MaxSize];
 5 
 6 int main()
 7 {
 8     //freopen("E:\\Temp\\input.txt", "r", stdin);
 9 
10     int K, expon, counter = 0;
11     double coef;
12     scanf("%d", &K);
13     for(int i=0; i<K; ++i) {
14         scanf("%d %lf", &expon, &coef);
15         List1[expon] += coef;
16     }
17     scanf("%d", &K);
18     for(int i=0; i<K; ++i) {
19         scanf("%d %lf", &expon, &coef);
20         for(int j=0; j<MaxSize; j++)
21             List2[expon+j] += List1[j]*coef;
22     }
23 
24     for(int i=0; i<MaxSize; ++i) {
25         if(List2[i] != 0)
26             ++counter;
27     }
28     printf("%d", counter);
29     for(int i=MaxSize-1; i>=0; --i) {
30         if(List2[i] != 0)
31             printf(" %d %.1f", i, List2[i]);
32     }
33 
34     return 0;
35 }

 1 #include <cstdio>
 2 
 3 struct Poly {
 4     int exp;
 5     double cof;
 6 }poly[1001];
 7 double ans[2001];
 8 
 9 int main()
10 {
11     int n, m, number = 0;
12     scanf("%d", &n);
13     for(int i=0; i<n; ++i)
14         scanf("%d %lf", &poly[i].exp, &poly[i].cof);
15     scanf("%d", &m);
16     for(int i=0; i<m; ++i) {
17         int exp;
18         double cof;
19         scanf("%d %lf", &exp, &cof);
20         for(int j=0; j<n; j++)
21             ans[exp+poly[j].exp] += (cof*poly[j].cof);
22     }
23 
24     for(int i=0; i<=2000; ++i) {
25         if(ans[i] != 0)
26             ++number;
27     }
28 
29     printf("%d", number);
30     for(int i=2000; i>=0; --i) {
31         if(ans[i] != 0)
32             printf(" %d %.1f", i, ans[i]);
33     }
34 
35     return 0;
36 }

各样输入蕴涵1个测试用例。每种测试用例先给出三个不超越一千的正整数N,随后给出N个不超过1000的待分类的正整数。数字间以空格分隔。

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     //freopen("E:\\Temp\\input.txt", "r", stdin);
 6 
 7     int T, tcase = 1;
 8     scanf("%d", &T);
 9     while(T--) {
10         long long a, b, c;
11         scanf("%lld%lld%lld", &a, &b, &c);
12         long long res = a+b;
13         bool flag;
14         if(a>0 && b>0 && res<0)
15             flag = true;
16         else if(a<0 && b<0 && res>=0)
17             flag = false;
18         else if(res > c)
19             flag = true;
20         else
21             flag = false;
22         if(flag == true)
23             printf("Case #%d: true\n", tcase++);
24         else
25             printf("Case #%d: false\n", tcase++);
26     }
27 
28     return 0;
29 }

Sample
Output:

 

Input:

Sample
Output:

输入在1行中逐条给出二个整数C一和C1。注意几次得到的机械钟照顾数肯定不雷同,即C1< C二,并且取值在[0, 107]。

Ouput:

在一行中输出PA +
PB的值。

Description:

给定区间[-231,
231]内的一个整数A、B和C,请剖断A+B是或不是高出C。

B1010.
壹元多项式求导 (贰五)

0

S1,
S2, …, S13, H1, H2, …, H13, C1, C2, …, C13, D1, D2, …, D13, J1,
J2

 

 1 #include <cstdio>
 2 
 3 #define MaxSize 1010
 4 double List[MaxSize];
 5 
 6 int main()
 7 {
 8     //freopen("E:\\Temp\\input.txt", "r", stdin);
 9 
10     int K, expon, counter = 0;
11     double coef;
12     scanf("%d", &K);
13     for(int i=0; i<K; ++i) {
14         scanf("%d %lf", &expon, &coef);
15         List[expon] += coef;
16     }
17     scanf("%d", &K);
18     for(int i=0; i<K; ++i) {
19         scanf("%d %lf", &expon, &coef);
20         List[expon] += coef;
21     }
22 
23     for(int i=0; i<MaxSize; ++i) {
24         if(List[i] != 0)
25             ++counter;
26     }
27     printf("%d", counter);
28     for(int i=MaxSize-1; i>=0; --i) {
29         if(List[i] != 0) {
30             printf(" %d %.1f", i, List[i]);
31         }
32     }
33 
34     return 0;
35 }

正整数A的“DA(为壹位平头)部分”定义为由A中全体DA构成的新整数PA。例如:给定A
= 3862767,DA =
6,则A的“6部分”PA是66,因为A中有2个6。

Sample
Output:

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     //freopen("E:\\Temp\\input.txt", "r", stdin);
 6 
 7     int n, step = 0;
 8     scanf("%d", &n);
 9 
10     while(n != 1) {
11         if(n%2 == 0) {
12             n /= 2;
13         } else {
14             n = (3*n+1)/2;
15         }
16         step++;
17     }
18 
19     printf("%d\n", step);
20 
21     return 0;
22 }

Output:

5

Output:

30 11
2 9.7 9

Sample
Output:

 

Input:

 

 1 #include <cstdio>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 const int MAXN = 100005;
 6 int dis[MAXN], A[MAXN];
 7 
 8 int main()
 9 {
10     int sum = 0, query, n, left, right;
11     scanf("%d", &n);
12     for(int i=1; i<=n; i++) {
13         scanf("%d", &A[i]);
14         sum += A[i];
15         dis[i] = sum;
16     }
17     scanf("%d", &query);
18     for(int i=0; i<query; i++) {
19         scanf("%d%d", &left, &right);
20         if(left > right)
21             swap(left, right);
22         int temp = dis[right-1]-dis[left-1];
23         printf("%d\n", min(temp, sum-temp));
24     }
25 
26     return 0;
27 }

定一文山会海正整数,请按供给对数字进行归类,并出口以下陆个数字:

Input:

8 1 2
4 5 6 7 9 16

 

3

Output:

 

A1046.Shortest
Distance (20)

 1 #include <cstdio>
 2 
 3 #define MaxSize 100010
 4 
 5 int school[MaxSize];
 6 
 7 int main()
 8 {
 9     //freopen("E:\\Temp\\input.txt", "r", stdin);
10 
11     int n, schID, score;
12     scanf("%d", &n);
13     for(int i=0; i<n; ++i) {
14         scanf("%d %d", &schID, &score);
15         school[schID] += score;
16     }
17 
18     int ID, maxscore = -1;
19     for(int i=1; i<=n; ++i) {
20         if(school[i] > maxscore) {
21             ID = i;
22             maxscore = school[i];
23         }
24     }
25 
26     printf("%d %d\n", ID, maxscore);
27 }

Sample
Input:

B十08.
数组成分循环右移难点 (20)

Input:

 

Sample
Input:

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     //freopen("E:\\Temp\\input.txt", "r", stdin);
 6 
 7     int T;
 8     long long a, b, c;
 9     scanf("%d", &T);
10     for(int i=1; i<=T; ++i) {
11         scanf("%lld %lld %lld", &a, &b, &c);
12         if(a+b > c) {
13             printf("Case #%d: true\n", i);
14         } else {
15             printf("Case #%d: false\n", i);
16         }
17     }
18 
19     return 0;
20 }
 1 #include <cstdio>
 2 
 3 #define MaxSize 3
 4 
 5 int ListA[MaxSize], ListB[MaxSize], Time[MaxSize];
 6 
 7 int main()
 8 {
 9     //freopen("E:\\Temp\\input.txt", "r", stdin);
10 
11     int N;
12     char c1, c2;
13     scanf("%d", &N);
14     for(int i=0; i<N; i++) {
15         getchar();
16         scanf("%c %c", &c1, &c2);
17             if(c1 == 'B') {
18                 if(c2 == 'B') {
19                     Time[1]++;
20                 } else if(c2 == 'C') {
21                     Time[0]++;
22                     ListA[0]++;
23                 } else {
24                     Time[2]++;
25                     ListB[2]++;
26                 }
27             } else if(c1 == 'C') {
28                 if(c2 == 'B') {
29                     Time[2]++;
30                     ListB[0]++;
31                 } else if(c2 == 'C') {
32                     Time[1]++;
33                 } else {
34                     Time[0]++;
35                     ListA[1]++;
36                 }
37             } else {
38                 if(c2 == 'B') {
39                     Time[0]++;
40                     ListA[2]++;
41                 } else if(c2 == 'C') {
42                     Time[2]++;
43                     ListB[1]++;
44                 } else {
45                     Time[1]++;
46                 }
47             }
48     }
49 
50     printf("%d %d %d\n%d %d %d\n", Time[0], Time[1], Time[2], Time[2], Time[1], Time[0]);
51     if(ListA[0] >= ListA[1]) {
52         if(ListA[0] >= ListA[2])
53             printf("B ");
54         else
55             printf("J ");
56     } else {
57         if(ListA[1] >= ListA[2])
58             printf("C ");
59         else
60             printf("J ");
61     }
62     if(ListB[0] >= ListB[1]) {
63         if(ListB[0] >= ListB[2])
64             printf("B\n");
65         else
66             printf("J\n");
67     } else {
68         if(ListB[1] >= ListB[2])
69             printf("C\n");
70         else
71             printf("J\n");
72     }
73 
74     return 0;
75 }

 1 #include <cstdio>
 2 
 3 int change(char c)
 4 {
 5     if(c == 'B')
 6         return 0;
 7     else if(c == 'C')
 8         return 1;
 9     else
10         return 2;
11 }
12 
13 int main()
14 {
15     //freopen("E:\\Temp\\input.txt", "r", stdin);
16 
17     char mp[3] = {'B', 'C', 'J'};
18     int n;
19     scanf("%d", &n);
20     int times_A[3] = {0}, times_B[3] = {0};
21     int hand_A[3] = {0}, hand_B[3] = {0};
22     char c1, c2;
23     int k1, k2;
24     for(int i=0; i<n; i++) {
25         getchar();
26         scanf("%c %c", &c1, &c2);
27         k1 = change(c1);
28         k2 = change(c2);
29         if((k1+1)%3 == k2) {
30             times_A[0]++;
31             times_B[2]++;
32             hand_A[k1]++;
33         } else if(k1 == k2) {
34             times_A[1]++;
35             times_B[1]++;
36         } else {
37             times_A[2]++;
38             times_B[0]++;
39             hand_B[k2]++;
40         }
41     }
42 
43     printf("%d %d %d\n", times_A[0], times_A[1], times_A[2]);
44     printf("%d %d %d\n", times_B[0], times_B[1], times_B[2]);
45     int id1 = 0, id2 = 0;
46     for(int i=0; i<3; i++) {
47         if(hand_A[i] > hand_A[id1])
48             id1 = i;
49         if(hand_B[i] > hand_B[id2])
50             id2 = i;
51     }
52     printf("%c %c\n", mp[id1], mp[id2]);
53 
54     return 0;
55 }

输入在壹行中相继给出A、DA、B、DB,中间以空格分隔,在那之中0
< A, B < 十10

The
task is really simple: given N exits on a highway which forms a simple
cycle, you are supposed to tell the shortest distance between any pair
of exits.

 

Discription:

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     //freopen("E:\\Temp\\input.txt", "r", stdin);
 6 
 7     int C1, C2;
 8     scanf("%d %d", &C1, &C2);
 9 
10     int ans = C2 - C1;
11     if(ans%100 < 50) {
12         ans /= 100;
13     } else {
14         ans = ans/100+1;
15     }
16 
17     printf("%02d:%02d:%02d\n", ans/3600, ans%3600/60, ans%60);
18 
19     return 0;
20 }

Each
input file contains one test case. Each case occupies 2 lines, and each
line contains the information of a polynomial: K N1 aN1 N2
aN2 … NK aNK, where K is the number of nonzero
terms in the polynomial, Ni and aNi (i=1, 2, …, K) are the
exponents and coefficients, respectively. It is given that 1 <= K
<= 10, 0 <= NK < … < N2 < N1 <=1000.

123
4577973

where
“S” stands for “Spade”, “H” for “Heart”, “C” for “Club”, “D” for
“Diamond”, and “J” for “Joker”. A given order is a permutation of
distinct integers in [1, 54]. If the number at the i-th position is j,
it means to move the card from position i to position j. For example,
suppose we only have 5 cards: S3, H5, C1, D13 and J2. Given a shuffling
order {4, 2, 5, 3, 1}, the result will be: J2, H5, D13, S3, C1. If we
are to repeat the shuffling again, the result will be: C1, H5, S3, J2,
D13.

12:42:59

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     //freopen("E:\\Temp\\input.txt", "r", stdin);
 6 
 7     int a[1010] = {0};
 8     int k, e, counter = 0;
 9     while(scanf("%d%d", &k, &e) != EOF) {
10         a[e] = k;
11     }
12     a[0] = 0;
13 
14     for(int i=1; i<=1000; ++i) {
15         a[i-1] = a[i]*i;
16         a[i] = 0;
17         if(a[i-1] != 0)
18             counter++;
19     }
20     if(counter == 0)
21         printf("0 0\n");
22     else {
23         for(int i=1000; i>=0; --i) {
24             if(a[i] != 0) {
25                 printf("%d %d", a[i], i);
26                 counter--;
27                 if(counter != 0)
28                     printf(" ");
29             }
30         }
31     }
32 
33     return 0;
34 }

B1011.
A+B和C (15)

 

咱俩前天的主题素材不是表明卡拉兹猜想,而是对给定的任1不超越1000的正整数n,轻便地数一下,须求某个步(砍几下)才具获得n=1?

图片 1

Sample
Input2:

Case
#1: false
Case
#2: true
Case
#3: false

2
150

10

Description:

The
machine shuffles a deck of 54 cards according to a given random order
and repeats for a given number of times. It is assumed that the initial
status of a card deck is in the following order:

Case
#1: false
Case
#2: true
Case
#3: true
Case
#4: false

This
time, you are supposed to find A*B where A and B are two
polynomials.

Input:

Input:

Output:

Input:

Description:

Sample
Input:

卡拉兹(Callatz)猜想:

This
time, you are supposed to find A+B where A and B are two
polynomials.

6
2
1 2 3
4 5 6

5 1 2
4 14 9
3
1
3
2
5
4
1

B101二.
数字分类 (20)

Sample
Output:

若里面某1类数字不存在,则在相应岗位输出“N”。

12 3
-10 1 6 0

现给定A、DA、B、DB,请编写程序总计PA +
PB

以指数递降形式输入多项式非零项周详和指数(相对值均为不超越一千的平头)。数字间以空格分隔。

Description:

2
36 52
37 38 3 39 40 53 54 41 11 12 13 42 43 44 2 4 23 24 25 26 27 6 7 8 48 49
50 51 9 10 14 15 16 5 17 18 19 1 20 21 22 28 29 30 31 32 33 34 35 45 46
47

399

10
C
J
J
B
C
B
B
B
B
C
C
C
C
B
J
B
B
C
J
J

Sample
Output:

For
each test case, output in one line “Case #X: true” if A+B>C, or
“Case #X: false” otherwise, where X is the case number (starting from
1).

B1016.
部分A+B (15)

 1 #include <cstdio>
 2 
 3 #define MaxSize 55
 4 
 5 int List1[MaxSize], List2[MaxSize], List3[MaxSize];
 6 
 7 int main()
 8 {
 9     //freopen("E:\\Temp\\input.txt", "r", stdin);
10 
11     int N, temp;
12     scanf("%d", &N);
13     for(int i=1; i<MaxSize; i++) {
14         List1[i] = i;
15         scanf("%d", &List2[i]);
16     }
17     for(int i=0; i<N; i++) {
18         for(int j=1; j<MaxSize; j++) {
19             List3[List2[j]] = List1[j];
20         }
21         for(int k=1; k<MaxSize; k++) {
22             List1[k] = List3[k];
23         }
24     }
25 
26     for(int i=1; i<MaxSize-1; i++) {
27         if(List1[i] > 52) {
28             printf("J%d ", List1[i]-52);
29         } else if(List1[i] > 39) {
30             printf("D%d ", List1[i]-39);
31         } else if(List1[i] > 26) {
32             printf("C%d ", List1[i]-26);
33         } else if(List1[i] > 13) {
34             printf("H%d ", List1[i]-13);
35         } else {
36             printf("S%d ", List1[i]);
37         }
38     }
39     if(List1[MaxSize-1] > 52) {
40         printf("J%d\n", List1[MaxSize-1]-52);
41     } else if(List1[MaxSize-1] > 39) {
42         printf("D%d\n", List1[MaxSize-1]-39);
43     } else if(List1[MaxSize-1] > 26) {
44         printf("C%d\n", List1[MaxSize-1]-26);
45     } else if(List1[MaxSize-1] > 13) {
46         printf("H%d\n", List1[MaxSize-1]-13);
47     } else {
48         printf("S%d\n", List1[MaxSize-1]);
49     }
50 
51     return 0;
52 }

 1 #include <cstdio>
 2 
 3 const int N = 54;
 4 char mp[5] = {'S', 'H', 'C', 'D', 'J'};
 5 int start[N], end[N], next[N];
 6 
 7 int main()
 8 {
 9     //freopen("E:\\Temp\\input.txt", "r", stdin);
10 
11     int K;
12     scanf("%d", &K);
13     for(int i=1; i<=N; i++)
14         start[i] = i;
15     for(int i=1; i<=N; i++)
16         scanf("%d", &next[i]);
17 
18     for(int step = 0; step < K; step++) {
19         for(int i=1; i<=N; i++)
20             end[next[i]] = start[i];
21         for(int i=1; i<=N; i++)
22             start[i] = end[i];
23     }
24 
25     for(int i=1; i<=N; i++) {
26         if(i != 1)
27             printf(" ");
28         start[i]--;
29         printf("%c%d", mp[start[i]/13], start[i]%13+1);
30     }
31 
32     return 0;
33 }

Input:

输入第二行提交正整数N(<=拾5),即双方交锋的次数。随后N行,每行给出一回交锋的消息,即甲、乙双方同时提交的的手势。C代表“锤子”、J代表“剪刀”、B代表“布”,第3个字母代表甲方,第三个代表乙方,中间有贰个空格。

Input:

The
first line of the input gives the positive number of test cases, T
(<=10). Then T test cases follow, each consists of a single line
containing three integers A, B and C, separated by single spaces.

在壹行中付出总得分最高的学堂的号码、及其总分,中间以空格分隔。标题保险答案唯1,未有比量齐观。

Input:

6
3
65
2
80
1
100
2
70
3
40
3
0

Output:

为了用实际证实发掘机本领到底哪家强,PAT组织了一场发现机技能大赛。现请你依照比赛结果总括入手艺最强的那些高校。

 

在一行中输出被测函数运维的时日。运行时刻必须依据“hh:mm:ss”(即3个人的“时:分:秒”)格式输出;不足一秒的时光4舍伍入到秒。

A1002.
A+B for Polynomials (25)

  • A1= 能被5整除的数字中持有偶数的和;
  • A2

    将被五除后余一的数字按给出顺序实行交错求和,即总计n一-n2+n3-n四…;

  • A3= 被五除后余二的数字的个数;
  • Huayra= 被伍除后余三的数字的平平均数量,准确到小数点后一个人;
  • A5= 被5除后余四的数字中最大数字。

Description:

Output:

3 2
1.5 1 2.9 0 3.2

Sample
Input2:

 

Sample
Output1:

7

Description:

Shuffling
is a procedure used to randomize a deck of playing cards. Because
standard shuffling techniques are seen as weak, and in order to avoid
“inside jobs” where employees collaborate with gamblers by performing
inadequate shuffles, many casinos employ automatic shuffling machines.
Your task is to simulate a shuffling machine.

Output:

Sample
Input:

Sample
Input:

For
each test case, print your results in M lines, each contains the
shortest distance between the corresponding given pair of exits.

Description:

A1009.
Product of Polynomials (25)

Sample
Input:

Description:

对每组测试用例,在1行中输出“Case
#X: true”借使A+B>C,不然输出“Case #X:
false”,在那之中X是测试用例的号子(从壹伊始)。

A1065.
A+B and C (64bit) (20)

在1行中输出循环右移M位未来的整数系列,之间用空格分隔,类别结尾不能够有剩余空格。

B十1八.
锤子剪刀布 (20)

3862767
1 13530293 8

For
each test case you should output the sum of A and B in one line, with
the same format as the input. Notice that there must be NO extra space
at the end of each line. Please be accurate to 1 decimal place.

Sample
Input:

2 1
2.4 0 3.2
2 2
1.5 1 0.5

Output:

5 3
2
2 3
5
B
B

B十二6.
程序运转时间 (15)

 

 1 #include <cstdio>
 2 
 3 #define MaxSize 5
 4 
 5 int List[MaxSize], ans[MaxSize];
 6 
 7 int main()
 8 {
 9     //freopen("E:\\Temp\\input.txt", "r", stdin);
10 
11     int N, temp;
12     scanf("%d", &N);
13     for(int i=0; i<N; ++i) {
14         scanf("%d", &temp);
15         if(temp%5 == 0) {
16             if(temp%2 == 0) {
17                 ans[0] += temp;
18                 List[0]++;
19             }
20         } else if(temp%5 == 1) {
21             if(List[1]%2 == 0) {
22                 ans[1] += temp;
23             } else {
24                 ans[1] -= temp;
25             }
26             List[1]++;
27         } else if(temp%5 == 2) {
28             List[2]++;
29         } else if(temp%5 == 3) {
30             ans[3] += temp;
31             List[3]++;
32         } else {
33             if(temp > ans[4]) {
34                 ans[4] = temp;
35             }
36             List[4]++;
37         }
38     }
39 
40     if(List[0] == 0) {
41         printf("N ");
42     } else {
43         printf("%d ", ans[0]);
44     }
45     if(List[1] == 0) {
46         printf("N ");
47     } else {
48         printf("%d ", ans[1]);
49     }
50     if(List[2] == 0) {
51         printf("N ");
52     } else {
53         printf("%d ", List[2]);
54     }
55     if(List[3] == 0) {
56         printf("N ");
57     } else {
58         printf("%.1f ", (double)ans[3]/List[3]);
59     }
60     if(List[4] == 0) {
61         printf("N\n");
62     } else {
63         printf("%d\n", ans[4]);
64     }
65 
66     return 0;
67 }

Input:

4
1 2
3
2 3
4
2147483647
0 2147483646
0
-2147483648 -2147483647

安排函数求壹元多项式的导数。(注:xn(n为整数)的一阶导数为n*xn-1。)

Description:

Output:

Sample
Input1:

Description:

Input:

Output:

输入第三行提交正整数T(<=10),是测试用例的个数。随后给出T组测试用例,每组占1行,顺序给出A、B和C。整数间以空格分隔。

Sample
Input:

Sample
Output1:

Output:

各类测试输入包涵贰个测试用例,即给出自然数n的值。

2 1
2.4 0 3.2
2 2
1.5 1 0.5

Output:

3
1 2
3
2 3
4
9223372036854775807
-9223372036854775808 0

Description:

Sample
Input:

对给定的N个正整数,按标题要求总结A一~A五并在壹行中各样输出。数字间以空格分隔,但行末不得有剩余空格。

3

Sample
Output:

For
each test case, print the shuffling results in one line. All the cards
are separated by a space, and there must be no extra space at the end of
the line.

Output:

Each
input file contains one test case. Each case occupies 2 lines, and each
line contains the information of a polynomial: K N1 aN1 N2
aN2 … NK aNK, where K is the number of nonzero
terms in the polynomial, Ni and aNi (i=1, 2, …, K) are the
exponents and coefficients, respectively. It is given that 1 <= K
<= 10,0 <= NK < … < N2 < N1 <=1000.

此间不要紧简要假如常数CLK_TCK为100。现给定被测函数前后两回获得的机械钟照料数,请你提交被测函数运维的日子。

B103二.
发掘机才具哪家强 (20)

 1 #include <cstdio>
 2 
 3 #define MaxSize 110
 4 
 5 int List[MaxSize];
 6 
 7 int main()
 8 {
 9     //freopen("E:\\Temp\\input.txt", "r", stdin);
10 
11     int N, M, counter = 1;
12     scanf("%d %d", &N, &M);
13     for(int i=0; i<N; ++i) {
14         scanf("%d", &List[i]);
15     }
16 
17     M %= N;
18     for(int i=N-M; i<N; ++i) {
19         if(counter != N) {
20             printf("%d ", List[i]);
21         } else {
22             printf("%d\n", List[i]);
23         }
24         counter++;
25     }
26     for(int i=0; i<N-M; ++i) {
27         if(counter != N) {
28             printf("%d ", List[i]);
29         } else {
30             printf("%d\n", List[i]);
31         }
32         counter++;
33     }
34 
35     return 0;
36 }

一个数组A中存有N(N>0)个整数,在不容许行使其它数组的前提下,将种种整数循环向右移M(M>=0)个职务,将要A中的数据由(A0A1……AN-1)变换为(AN-M ……
AN-1 A0 A1……AN-M-1)(末了M个数循环移至最前边的M个地方)。假如须要思量程序移动数据的次数尽量少,要如何设计活动的措施?

Sample
Output:

5 6 1
2 3 4

对别的贰个自然数n,如若它是偶数,那么把它砍掉四分之二;借使它是奇数,那么把(三n+一)砍掉3/六。那样直接反复拿下去,最后必就要某一步得到n=壹。卡拉兹在一九四八年的社会风气地军事学家大会上公布了那个臆度,传说当时佐治亚理工高校师生齐动员,拼命想表明那些一般很傻很天真的命题,结果闹得学生们无心学业,一心只证(三n+一),以致于有人说那是3个阴谋,卡拉兹是在故意延缓美国数学界教学与调研的实行……

留下评论

网站地图xml地图