• wenbao与蓝桥


    http://lx.lanqiao.cn/problem.page?gpid=T31

    买不到的礼物

    结论 a*b-a-b

     1 #include <iostream>
     2 #include <string.h>
     3 using namespace std;
     4 const int maxn = 2e5+10;
     5 bool vis[maxn];
     6 int main(){
     7     int x, y;
     8     scanf("%d%d", &x, &y);
     9     vis[x] = vis[y] = true;
    10     vis[0] = true;
    11     for(int i = min(x, y)+1; i < maxn; ++i){
    12         if(i-x >= 0 && vis[i-x]) vis[i] = true;
    13         if(i-y >= 0 && vis[i-y]) vis[i] = true;
    14     }
    15     for(int i = maxn - 1; i >= 0; --i){
    16         if(!vis[i]){
    17             printf("%d
    ", i);
    18             break;
    19         }
    20     }
    21     return 0;
    22 }

     ---------------------------------------------------------------------------------------------------------------------------------------------

     6*6方格拆分

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <queue>
     5 using namespace std;
     6 int sum = 0;
     7 void read(char d[6][6]){
     8     for(int i = 0; i < 6; ++i){
     9         for(int j = 0; j < 6; ++j){
    10             printf("%c", d[i][j]);
    11         }
    12         printf("
    ");
    13     }
    14 }
    15 void read2(bool vis[6][6]){
    16     for(int i = 0; i < 6; ++i){
    17         for(int j = 0; j < 6; ++j){
    18             printf("%d", vis[i][j]);
    19         }
    20         printf("
    ");
    21     }
    22 }
    23 bool vis[6][6];
    24 char ss[6][6];
    25 int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};
    26 int num;
    27 void f(int x, int y){
    28     for(int i = 0; i < 4; ++i){
    29         int xx = x + dir[i][0];
    30         int yy = y + dir[i][1];
    31         if(xx >= 0 && xx < 6 && yy >= 0 && yy < 6 && !vis[xx][yy] && ss[xx][yy] == ss[x][y]){
    32             vis[xx][yy] = true, num ++;
    33             f(xx, yy);
    34         }
    35     }
    36 }
    37 bool ok2(char c[6][6]){
    38     
    39 }
    40 bool ok(char c[6][6]){
    41     memcpy(ss, c, sizeof(ss));
    42     //read(ss);
    43     memset(vis, false, sizeof(vis));
    44     vis[0][0] = true;
    45     num = 1;
    46     f(0, 0);
    47     //cout<<"**************"<<endl;
    48     //read2(vis);
    49     //cout<<num<<endl;
    50     if(num == 18 && ok2(c)){
    51         //cout<<"***************"<<endl;
    52         //read2(vis);
    53         return true;
    54     }
    55     else return false;
    56 }
    57 void g(int x, int y, char c[6][6]){
    58     if(x == 2 && y == 6){
    59         if(ok(c)){
    60             //cout<<"******************"<<endl;
    61             //read(c);
    62             sum ++;
    63         }
    64         return ;
    65     }
    66     if(y == 6) y = 0, x++;
    67     c[x][y] = '0', c[5-x][5-y] = '1';
    68     g(x, y+1, c);
    69     c[x][y] = '1', c[5-x][5-y] = '0';
    70     g(x, y+1, c);
    71 }
    72 int main(){
    73     char a[6][6];
    74     memset(a, '1', sizeof(a));
    75     g(0, 0, a);
    76     printf("%d
    ", sum/4);
    77     //2036   509
    78     //cout<<(1<<18)<<endl;
    79     return 0;
    80 }

    --------------------------------------------------------------------------------------------------------------------------------------------- 

     垃圾题目

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <stdio.h>
     4 #include <map>
     5 using namespace std;
     6 //年/月/日的,有采用月/日/年的,还有采用日/月/年
     7 //1960年1月1日至2059年12月31日
     8 int x[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
     9 int num = 0;
    10 bool ok(int x){
    11     if((x%4 == 0 && x %100 != 0) || x%400 == 0) return true;
    12     else return false;
    13 }
    14 struct Node{
    15     int y, m, d;
    16 }T[10];
    17 bool cmp(Node a, Node b){
    18     if(a.y == b.y){
    19         if(a.m == b.m) return a.d < b.d;
    20         else return a.m < b.m;
    21     }
    22     return a.y < b.y;
    23 }
    24 map<int,bool> M;
    25 void g(int y, int m, int d){
    26     if(y >= 60) y += 1900;
    27     else y += 2000;
    28     if(m > 12) return;
    29     int xx = x[m];
    30     if(m == 2 && ok(y)) xx ++;
    31     if(d > xx) return;
    32     T[num].y = y, T[num].m = m, T[num].d = d;
    33     int xxx = m*100+y*10000+d;
    34     M[xxx] = true;
    35     num ++;
    36 }
    37 int main(){
    38     int a, b, c;
    39     scanf("%d/%d/%d", &a, &b, &c);
    40     printf("%d %d %d
    ", a, b, c);
    41     g(a, b, c);
    42     g(c, a, b);
    43     g(c, b, a);
    44     sort(T, T+num, cmp);
    45     for(int i = 0; i < num; ++i){
    46         int xxx = T[i].m*100+T[i].y*10000+T[i].d;
    47         if(M[xxx]){
    48             printf("%d-%02d-%02d
    ", T[i].y, T[i].m, T[i].d);
    49             M[xxx] = false;
    50         }
    51     }
    52     return 0;
    53 }

    ---------------------------------------------------------------------------------------------------------------------------------------------

    严重怀疑蓝桥的cb有问题,同样的代码在比赛的时候打死跑不出来(跑出来也不对),在我的电脑上一秒就出来了,好气。。。。。。。。。。。

     1 #include <iostream>
     2 using namespace std;
     3 int num = 0;
     4 int a[4][11];
     5 bool ok(){
     6     for(int i = 1; i <= 2; ++i){
     7         for(int j = 1; j <= 9; ++j){
     8             bool flag = false;
     9             if(a[i][j] != a[i][j+1]) flag = true;
    10             if(a[i][j] != a[i+1][j+1]) flag = true;
    11             if(a[i][j] != a[i+1][j]) flag = true;
    12             if(a[i][j+1] != a[i+1][j+1]) flag = true;
    13             if(a[i][j+1] != a[i+1][j]) flag = true;
    14             if(a[i+1][j] != a[i+1][j+1]) flag = true;
    15             if(!flag) return false;
    16         }
    17     }
    18     return true;
    19 }
    20 void d(int x, int y){
    21     if(y > 10) x ++, y = 1;
    22     if(x == 4) {
    23         if(ok()) num ++;
    24         return ;
    25     }
    26     if(a[x][y]){
    27         d(x, y+1);
    28     }else{
    29         if(y+1 <= 10 && !a[x][y+1]){
    30             a[x][y] = a[x][y+1] = 1, d(x, y+2);
    31             a[x][y] = a[x][y+1] = 2, d(x, y+2);
    32             a[x][y] = a[x][y+1] = 0;
    33         }
    34         if(x+1 <= 3 && !a[x+1][y]){
    35             a[x][y] = a[x+1][y] = 1, d(x, y+1);
    36             a[x][y] = a[x+1][y] = 2, d(x, y+1);
    37             a[x][y] = a[x+1][y] = 0;
    38         }
    39     }
    40 }
    41 int main(){
    42     d(1, 1);
    43     printf("%d
    ", num);
    44     return 0;
    45 }

     ---------------------------------------------------------------------------------------------------------------------------------------------

    只有不断学习才能进步!

  • 相关阅读:
    B507实验室打印机连接方法
    2016年武汉大学计算机学院“新技术系列讲座”简介记录
    使用SpringBoot快速构建应用程序
    UIColor,CGColor,CIColor三者的区别和联系
    Objective C中NULL、Nil、nil、NSNull 的区别
    iOS 部分机制
    常见排序算法-采用Objective-c实现
    iOS的永久存储
    网络协议初探
    iOS多线程编程之Grand Central Dispatch(GCD)介绍和使用
  • 原文地址:https://www.cnblogs.com/wenbao/p/6693153.html
Copyright © 2020-2023  润新知