*推销员


1 #include<bits/stdc++.h>
2 using namespace std;
3 int main()
4 {
5 std::ios::sync_with_stdio(false);
6 int k , minN = 9999999 , a , b;
7 cin >> k;
8 for(int i = 0 ; i < 3 ; i++)
9 {
10 cin >> a >> b;
11 minN = min(minN , (k / a + (k % a != 0)) * b);
12 }
13 cout << minN;
14 return 0;
15 }
买铅笔


1 //随便枚举
2 #include<bits/stdc++.h>
3 using namespace std;
4 int main(){
5 int n , m , num = 0;
6 cin >> n >> m;
7 for(int i = 1 , j = 1 ; i + j < 44 ; j++)
8 {
9 if(j == 32 && (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) || j == 31 && (i == 9 || i == 4 || i == 6 || i == 11) || j == 30 && i == 2)
10 {
11 j = 1;
12 i++;
13 }
14 if(j % 10)
15 {
16 int y = j % 10 * 10000000 + j / 10 * 1000000 + i % 10 * 100000 + i / 10 * 10000 + i * 100 + j;
17 if(y >= n && y <= m)
18 num++;
19 }
20 }
21 cout << num;
22 return 0;
23 }
回文日期


1 //双指针优化枚举
2 #include<bits/stdc++.h>
3 #define MAXN 100001
4 using namespace std;
5 int appear[MAXN] , t[MAXN] , k[MAXN];
6 vector < int > peo[MAXN];
7 int main()
8 {
9 ios::sync_with_stdio(0);
10 cin.tie(0);
11 cout.tie(0);
12 int ans = 0 , N , dir = 1;
13 cin >> N;
14 for(int i = 1 ; i <= N ; i++){
15 cin >> t[i] >> k[i];
16 for(int j = 0 ; j < k[i] ; j++){
17 int a;
18 cin >> a;
19 peo[i].push_back(a);
20 if(!appear[a]++)
21 ans++;
22 }
23 while(t[i] - t[dir] >= 86400){
24 for(int j = 0 ; j < k[dir] ; j++)
25 if(!--appear[peo[dir][j]])
26 ans--;
27 dir++;
28 }
29 cout << ans << endl;
30 }
31 return 0;
32 }
海港


1 //换元、前缀和优化
2 #include<bits/stdc++.h>
3 //This code is written by Itst
4 using namespace std;
5
6 inline int read(){
7 int a = 0;
8 bool f = 0;
9 char c = getchar();
10 while(c != EOF && !isdigit(c)){
11 if(c == '-')
12 f = 1;
13 c = getchar();
14 }
15 while(c != EOF && isdigit(c)){
16 a = (a << 3) + (a << 1) + (c ^ '0');
17 c = getchar();
18 }
19 return f ? -a : a;
20 }
21
22 int pot[15010] , num[40010] , A[15010] , B[15010] , C[15010] , D[15010];
23
24 int main(){
25 #ifndef ONLINE_JUDGE
26 freopen("2119.in" , "r" , stdin);
27 //freopen("2119.out" , "w" , stdout);
28 #endif
29 int N = read() , M = read();
30 for(int i = 1 ; i <= M ; i++)
31 ++pot[num[i] = read()];
32 for(int i = 1 ; i * 9 < N ; i++){
33 int sum = 0;
34 for(int d = 9 * i + 2 ; d <= N ; d++){
35 int c = d - i;
36 sum += pot[d - 7 * i - 1] * pot[d - 9 * i - 1];
37 C[c] += sum * pot[d];
38 D[d] += sum * pot[c];
39 }
40 sum = 0;
41 for(int a = N - 9 * i - 1 ; a ; a--){
42 int b = a + 2 * i;
43 sum += pot[b + 6 * i + 1] * pot[b + 7 * i + 1];
44 B[b] += sum * pot[a];
45 A[a] += sum * pot[b];
46 }
47 }
48 for(int i = 1 ; i <= M ; i++)
49 printf("%d %d %d %d\n" , A[num[i]] , B[num[i]] , C[num[i]] , D[num[i]]);
50 return 0;
51 }
*魔法阵


1 #include<bits/stdc++.h>
2 using namespace std;
3 int main(){
4 int a , b , c;
5 cin >> a >> b >> c;
6 cout << a / 5 + b / 10 * 3 + c / 2;
7 return 0;
8 }
成绩


1 #include<bits/stdc++.h>
2 using namespace std;
3 int book[1001];
4 int main()
5 {
6 int n , q;
7 cin >> n >> q;
8 for(int i = 1 ; i <= n ; i++)
9 cin >> book[i];
10 sort(book + 1 , book + n + 1);
11 while(q--){
12 int l , a , i;
13 cin >> l >> a;
14 l = pow(10 , l);
15 for(i = 1 ; i <= n ; i++)
16 if(book[i] % l == a)
17 break;
18 if(i == n + 1)
19 cout << -1 << endl;
20 else
21 cout << book[i] << endl;
22 }
23 return 0;
24 }
图书管理员


1 //瞎搞图论
2 #include<bits/stdc++.h>
3 #define inf 0x3f3f3f3f
4 #define X now.x + dir[i][0]
5 #define Y now.y + dir[i][1]
6 //This code is written by Itst
7 using namespace std;
8
9 inline int read(){
10 int a = 0;
11 bool f = 0;
12 char c = getchar();
13 while(c != EOF && !isdigit(c)){
14 if(c == '-')
15 f = 1;
16 c = getchar();
17 }
18 while(c != EOF && isdigit(c)){
19 a = (a << 3) + (a << 1) + (c ^ '0');
20 c = getchar();
21 }
22 return f ? -a : a;
23 }
24
25 struct node{
26 int x , y , col;
27 }now;
28 const int dir[4][2] = {0 , 1 , 0 , -1 , 1 , 0 , -1 , 0};
29 int minDis[102][102][3] , col[102][102] , M , N;
30 queue < node > q;
31
32 void SPFA(){
33 memset(minDis , 0x3f , sizeof(minDis));
34 minDis[1][1][col[1][1]] = 0;
35 q.push((node){1 , 1 , col[1][1]});
36 while(!q.empty()){
37 now = q.front();
38 q.pop();
39 for(int i = 0 ; i < 4 ; i++)
40 if(col[X][Y] + 1)
41 if(col[X][Y] || col[now.x][now.y]){
42 if(col[X][Y]){
43 if(minDis[X][Y][col[X][Y]] > minDis[now.x][now.y][now.col] + (now.col != col[X][Y])){
44 minDis[X][Y][col[X][Y]] = minDis[now.x][now.y][now.col] + (now.col != col[X][Y]);
45 q.push((node){X , Y , col[X][Y]});
46 }
47 }
48 else{
49 col[X][Y] = now.col;
50 if(minDis[X][Y][col[X][Y]] > minDis[now.x][now.y][now.col] + 2){
51 minDis[X][Y][col[X][Y]] = minDis[now.x][now.y][now.col] + 2;
52 q.push((node){X , Y , col[X][Y]});
53 }
54 col[X][Y] = 0;
55 }
56 }
57 }
58 }
59
60 int main(){
61 #ifndef ONLINE_JUDGE
62 freopen("3956.in" , "r" , stdin);
63 //freopen("3956.out" , "w" , stdout);
64 #endif
65 memset(col , -1 , sizeof(col));
66 M = read();
67 N = read();
68 for(int i = 1 ; i <= M ; i++)
69 for(int j = 1 ; j <= M ; j++)
70 col[i][j] = 0;
71 while(N--){
72 int a = read() , b = read() , c = read() + 1;
73 col[a][b] = c;
74 }
75 SPFA();
76 if(minDis[M][M][0] == inf && minDis[M][M][1] == inf && minDis[M][M][2] == inf)
77 puts("-1");
78 else
79 printf("%d\n" , min(minDis[M][M][0] , min(minDis[M][M][1] , minDis[M][M][2])));
80 return 0;
81 }
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-124192-11.html
我们有那么多的怕死将军和不敢站元帅
更像是一个小帮派的首领
我们加紧建设我们的