PassThePAT


  • 首页

  • 标签

  • 分类

  • 归档

  • 搜索

1018 Public Bike Management

发表于 2020-05-30

1017 Queueing at Bank

发表于 2020-05-30

1016 Phone Bills

发表于 2020-05-30

1015 Reversible Primes

发表于 2020-05-30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;

bool isPrime(int n) {
if (n <= 1) return false; // 1不是素数
int sqr = (int)sqrt(1.0 * n);
for (int i = 2; i <= sqr; i++)
if (n % i == 0) return false;
return true;
}

int reverseN(int n, int d) {
int arr[100] = {0}, len = 0;
while (n) {
arr[len++] = n % d;
n /= d;
}
int res = 0;
for (int i = 0; i < len; i++) {
res = res * d + arr[i];
}
return res;
}

int main() {
int n, d;
while (scanf("%d", &n) != EOF && n > 0) {
scanf("%d", &d);
if (!isPrime(n)) {
printf("No\n");
continue;
}
n = reverseN(n, d);
printf("%s", isPrime(n) ? "Yes\n" : "No\n");
}

return 0;
}


73 10
23 2
23 10
-2

Yes
Yes
No

1014 Waiting in Line

发表于 2020-05-30

1013 Battle Over Cities

发表于 2020-05-30

1012 The Best Rank

发表于 2020-05-30

1011 World Cup Betting

发表于 2020-05-30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;

int main() {
char c[4] = {"WTL"};
double res = 1.0;
for (int i = 0; i < 3; i++) {
double maxVal = 0.0;
int maxChar = 0;
for (int j = 0; j < 3; j++) {
double temp;
scanf("%lf", &temp);
if (temp > maxVal) {
maxVal = temp;
maxChar = j;
}
}
res *= maxVal;
printf("%c ", c[maxChar]);
}
printf("%.2f", (res * 0.65 - 1) * 2);

return 0;
}


1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1

T T W 39.31

1010 Radix

发表于 2020-05-30

1009 Product of Polynomials

发表于 2020-05-30

题目大意:
求2个多项式A*B后的结果。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;

int main() {
int k1, k2, cnt = 0, exp;
double coe, arr[1001] = {0.0}, ans[2001] = {0.0};
scanf("%d", &k1);
for (int i = 0; i < k1; i++) {
scanf("%d %lf", &exp, &coe);
arr[exp] += coe;
}
scanf("%d", &k2);
for (int i = 0; i < k2; i++) {
scanf("%d %lf", &exp, &coe);
for (int j = 0; j <= 1000; j++) {
ans[j + exp] += arr[j] * coe;
}
}
for (int i = 2000; i >= 0; i--) {
if (ans[i]) cnt++;
}
printf("%d", cnt);
for (int i = 2000; i >= 0; i--) {
if (ans[i])
printf(" %d %.1f", i, ans[i]);
}

return 0;
}


2 1 2.4 0 3.2
2 2 1.5 1 0.5

3 3 3.6 2 6.0 1 1.6
1…141516

e5

158 日志
5 标签
© 2022 e5
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4