西南弱校联萌
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了西南弱校联萌相关的知识,希望对你有一定的参考价值。
A. 垃圾题目毁我青春(3n+1猜想 || 模拟)
Sample Input
5
Sample Output
YES
Hint
对于样例1:1 -> 2 -> 4 -> 8 -> 16 -> 5
Solve:
可以直接从n模拟(模拟就变成了3*n+1猜想了),所以很明显他是都是yes的
Code:
1 #pragma comment(linker, "/STACK:36777216") 2 3 #include <bits/stdc++.h> 4 using namespace std; 5 #define LSON id << 1 , l , mid 6 #define RSON id << 1 | 1 , mid + 1 , r 7 #define ROOT 1 , 1 , n 8 #define CLR(x , y) memset(x , y , sizeof(x)) 9 #define LOWBIT(x) x & (-x) 10 #define FORN(i , a , n) for(int i = (a) ; i <= (n) ; ++i) 11 #define FORP(i , n , a) for(int i = (n) ; i >= (a) ; --i) 12 #define CASE(x) printf("Case %d: ", x) 13 #define SFD(x) scanf("%lf" , &x) 14 #define SFC(x) scanf(" %c" , &x) 15 #define SFS(x) scanf(" %s" , x) 16 #define SFI(x) scanf("%d" , &x) 17 #define SFL(x) scanf("%lld" , &x) 18 #define SFI64(x) scanf("%I64d" , &x) 19 #define PFF(x) printf("%f" , x) 20 #define PFD(x) printf("%lf" , x) 21 #define PFI(x) printf("%d" , x) 22 #define PFC(x) printf("%c" , x) 23 #define PFS(x) printf("%s" , x) 24 #define PFI64(x) printf("%I64d" , x) 25 #define PFL(x) printf("%lld\\n" , x) 26 #define SPACE printf(" ") 27 #define PUT puts("") 28 #define LPUP(i , j , k) for(int i = j ; i <= k ; ++i) 29 #define LPDW(i , j , k) for(int i = j ; i >= k ; --i) 30 #define PB(x) push_back(x) 31 #define ALL(A) A.begin(), A.end() 32 #define SZ(A) int((A).size()) 33 #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) 34 #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) 35 #define LOCAL 36 static const double PI = acos(-1.0); 37 static const double EPS = 1e-8; 38 static const int INF = 0X3fffffff; 39 typedef long long LL; 40 typedef double DB; 41 template<class T> inline 42 T read(T &x) 43 { 44 x = 0; 45 int f = 1 ; char ch = getchar(); 46 while (ch < ‘0‘ || ch > ‘9‘) {if (ch == ‘-‘) f = -1; ch = getchar();} 47 while (ch >= ‘0‘ && ch <= ‘9‘) {x = x * 10 + ch - ‘0‘; ch = getchar();} 48 x *= f; 49 } 50 51 /************************Little Pea****************************/ 52 53 static const int MAXN = 1e9 + 10; 54 static const int qwq = 1e6 + 10; 55 56 int i; 57 int main() 58 { 59 #ifndef ONLINE_JUDGE 60 //freopen("D:\\\\系统优化\\\\Desktop\\\\littlepea\\\\in.data" , "r" , stdin); 61 #endif 62 while(~SFI(i)) 63 { 64 puts("YES"); 65 } 66 67 #ifndef ONLINE_JUDGE 68 fclose(stdin), fclose(stdout); 69 #endif 70 }
B. 孤独的串(水题)
Solve:
直接判断一个字符出现的次数是否大于1就可以了
Code:
1 #pragma comment(linker, "/STACK:36777216") 2 3 #include <bits/stdc++.h> 4 using namespace std; 5 #define LSON id << 1 , l , mid 6 #define RSON id << 1 | 1 , mid + 1 , r 7 #define ROOT 1 , 1 , n 8 #define CLR(x , y) memset(x , y , sizeof(x)) 9 #define LOWBIT(x) x & (-x) 10 #define FORN(i , a , n) for(int i = (a) ; i <= (n) ; ++i) 11 #define FORP(i , n , a) for(int i = (n) ; i >= (a) ; --i) 12 #define CASE(x) printf("Case %d: ", x) 13 #define SFD(x) scanf("%lf" , &x) 14 #define SFC(x) scanf(" %c" , &x) 15 #define SFS(x) scanf(" %s" , x) 16 #define SFI(x) scanf("%d" , &x) 17 #define SFL(x) scanf("%lld" , &x) 18 #define SFI64(x) scanf("%I64d" , &x) 19 #define PFF(x) printf("%f" , x) 20 #define PFD(x) printf("%lf" , x) 21 #define PFI(x) printf("%d" , x) 22 #define PFC(x) printf("%c" , x) 23 #define PFS(x) printf("%s" , x) 24 #define PFI64(x) printf("%I64d" , x) 25 #define PFL(x) printf("%lld\\n" , x) 26 #define SPACE printf(" ") 27 #define PUT puts("") 28 #define LPUP(i , j , k) for(int i = j ; i <= k ; ++i) 29 #define LPDW(i , j , k) for(int i = j ; i >= k ; --i) 30 #define PB(x) push_back(x) 31 #define ALL(A) A.begin(), A.end() 32 #define SZ(A) int((A).size()) 33 #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) 34 #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) 35 #define LOCAL 36 static const double PI = acos(-1.0); 37 static const double EPS = 1e-8; 38 static const int INF = 0X3fffffff; 39 typedef long long LL; 40 typedef double DB; 41 template<class T> inline 42 T read(T &x) 43 { 44 x = 0; 45 int f = 1 ; char ch = getchar(); 46 while (ch < ‘0‘ || ch > ‘9‘) {if (ch == ‘-‘) f = -1; ch = getchar();} 47 while (ch >= ‘0‘ && ch <= ‘9‘) {x = x * 10 + ch - ‘0‘; ch = getchar();} 48 x *= f; 49 } 50 51 /************************Little Pea****************************/ 52 static const int MAXN = 1e5 + 10; 53 char data[MAXN]; 54 bool vis[MAXN]; 55 int main() 56 { 57 #ifndef ONLINE_JUDGE 58 //freopen("D:\\\\系统优化\\\\Desktop\\\\littlepea\\\\in.data" , "r" , stdin); 59 #endif 60 int t; 61 read(t); 62 int n; 63 while(t--) 64 { 65 bool flag = 1; 66 CLR(vis , 0); 67 read(n); 68 SFS(data + 1); 69 LPUP(i , 1 , n) 70 { 71 if(vis[data[i] - ‘a‘]) 72 { 73 flag = 0; 74 } 75 vis[data[i] - ‘a‘] = 1; 76 } 77 if(flag) 78 puts("Yes"); 79 else 80 puts("No"); 81 } 82 83 84 #ifndef ONLINE_JUDGE 85 fclose(stdin), fclose(stdout); 86 #endif 87 }
以上是关于西南弱校联萌的主要内容,如果未能解决你的问题,请参考以下文章
弱校联萌十一大决战之背水一战C. Counting Pair