Loading... [2021吉林省省赛正式赛题面.pdf](https://whksoft.cn/usr/uploads/2021/11/269704544.pdf) [CF站在线撸代码](https://codeforces.com/gym/103486) ``` /** * A Random Number Checker **/ #include <stdio.h> #include <math.h> int isodd(int a){ return a%2; } int main(){ int n,odd=0,even=0; scanf("%d",&n); for(int i = 0; i<n;i++){ int a; scanf("%d",&a); if(isodd(a)) odd++; else even++; } if(abs(odd-even)<=1){ printf("Good"); } else printf("Not Good"); } ``` ``` /** * B Arithmetic Exercise **/ #include <stdio.h> #include <malloc.h> int* arr; void div(int a, int b, int k, int i){ if(k+1 == i){ return; } arr[i] = a/b; a%=b; div(a*10,b,k,i+1); } int main(){ int a,b,k; scanf("%d%d%d",&a,&b,&k); arr = (int*)malloc(sizeof(int)*(k+2)); div(a,b,k+1,0); for(int i=k+1;i>=0;i--) { if(i==k+1&&arr[i]>=5) arr[i-1]++; else if(arr[i]>=10) { arr[i-1]++; arr[i]-=10; } else continue; } for(int i=0;i<=k;i++){ printf("%d",arr[i]); if(i==0) printf("."); } } ``` ``` /** * E Great Detective TJC **/ #include <stdio.h> #include <malloc.h> #include <algorithm> using namespace std; int fl = 0; void cmp(int a, int b){ if(a-b==1 && a%2) { fl=1; return; } if(b-a==1 && b%2) { fl=1; return; } } int main(){ int t; scanf("%d",&t); while(t--){ fl=0; int n; scanf("%d",&n); int* arr = (int*)malloc(sizeof(int)*n); for(int i=0;i<n;i++){ scanf("%d",arr+i); } sort(arr, arr+n); for(int i=0;i<n-1;i++){ if(fl) break; cmp(arr[i], arr[i+1]); } if(t==0){ if(fl) printf("Yes"); else printf("No"); } else { if(fl) printf("Yes\n"); else printf("No\n"); } } } ``` ``` /** * G Matrix Repair **/ #include<bits/stdc++.h> using namespace std; #define endl "\n" int arr[1005][1005]; int a[1005]; int b[1005]; int aa[1005]; int bb[1005]; int main(){ ios::sync_with_stdio(false); int n; while(cin >> n){ //empty memset(aa, 0, sizeof(aa)); memset(bb, 0, sizeof(bb)); //sample input for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ cin >> arr[i][j]; if(arr[i][j] == -1){ aa[i]++; bb[j]++; } } } for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= n; i++){ cin >> b[i]; } bool f = 0; while(1){ bool flag = 0; int ans = -1; for(int i = 1; i <= n; i++){ if(aa[i] != 0){ flag = 1; } if(aa[i] == 1){ ans = i; break; } } if(ans == -1){ for(int i = 1; i <= n; i++){ if(bb[i] != 0){ flag = 1; } if(bb[i] == 1){ ans = i; break; } } if(ans == -1){ //If there is no row or column with only one - 1, it will jump out if(flag == 0){//If there is no - 1, the sequence can be output f = 1; break; } cout << "-1" << endl; break; }else{ int cnt = 0; int num = 0; for(int i = 1; i <= n; i++){ if(arr[i][ans] == 1){ cnt++; }else if(arr[i][ans] == -1){ num = i; } } bb[ans]--; aa[num]--; if(b[ans] & 1 && cnt & 1){ arr[num][ans] = 0; }else if(b[ans] % 2 == 0 && cnt % 2 == 0){ arr[num][ans] = 0; }else{ arr[num][ans] = 1; } } }else{ //Go to that line to update - 1 int cnt = 0; int num = 0; for(int i = 1; i <= n; i++){ if(arr[ans][i] == 1){ cnt++; }else if(arr[ans][i] == -1){ num = i; } } bb[num]--; aa[ans]--; if(a[ans] & 1 && cnt & 1){ arr[ans][num] = 0; }else if(a[ans] % 2 == 0 && cnt % 2 == 0){ arr[ans][num] = 0; }else{ arr[ans][num] = 1; } } } if(f){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(j != 1){ cout << " "; } cout << arr[i][j]; } cout << endl; } } } return 0; } ``` ``` /** * H Visit the Park **/ #include <bits/stdc++.h> using namespace std; #define FI first #define SE second #define MP make_pair #define PB push_back typedef pair<int, int> PII; typedef vector<int> VI; const int mod = 998244853; const int N = 3e5 + 10; map<PII, VI> mp; map<PII, PII> edg; int a[N]; LL qi(LL a) { LL ans = 1; int p = mod - 2; while (p ) { if (p & 1) ans = ans * a % mod; a = a * a % mod; p >>= 1; } return ans; } int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= m; i ++ ) { int u, v, w; scanf("%d%d%d", &u, &v, &w); if (u < v) mp[MP(u, v)].PB(w); else mp[MP(v, u)].PB(w); } LL ans = 0; LL pos = 1; LL t = qi(10); bool ok = 1; for (int i = 1; i < k - 1; i ++ ) pos = pos * 10 % mod; for (int i = 1; i <= k; i ++ ) scanf("%d", a + i); for (int i = 1; i < k; i ++ ) { int u = min(a[i], a[i + 1]), v = max(a[i], a[i + 1]); VI tmp = mp[MP(u, v)]; int len = tmp.size(); if (len == 0) { ok = 0; break; } LL key = qi(len); for (int j = 0; j < len; j ++ ) { ans = (ans + ((pos * tmp[j]) % mod * key) % mod) % mod; } pos = pos * t % mod; } if (ok) cout << ans << endl; else cout << "Stupid Msacywy!" << endl; return 0; } ``` ``` /** * K Bracket Sequence **/ #include <bits/stdc++.h> using namespace std; typedef long long LL; const int mod = 1e9 + 7; const int N = 2e5 + 10; LL base[N], inv[N]; LL qi(LL a) { LL ans = 1; int p = mod - 2; while (p) { if (p & 1) ans = ans * a % mod; a = a * a % mod; p >>= 1; } return ans; } int main() { int n, k; cin >> n >> k; LL b = 1; for (int i = 1; i <= n; i ++ ) b = b * k % mod; base[0] = 1; for (int i = 1; i <= 2 * n; i ++ ) { base[i] = base[i - 1] * i % mod; if (i == n) inv[i] = qi(base[i]); } LL x = qi(n + 1); cout << (((base[2 * n] * inv[n] % mod) * inv[n] % mod) * x % mod)* b % mod << endl; return 0; } ``` ``` /** * L Suzuran Loves String **/ #include <stdio.h> #include <string.h> #include <malloc.h> int cnt = 0; int isDin(char* s){ for(int i=1;*(s+i)!=0;i++){ if(s[i] != s[0]){ return 1; } cnt++; } return 0; } int main(){ int t; scanf("%d",&t); while(t--){ cnt=0; char* s = (char*)malloc(sizeof(char)*1000000); scanf("%s",s); if(isDin(s)){ printf("%d\n",strlen(s)*2-1-cnt); } else printf("%d\n",strlen(s)-1); } } ``` ``` /** * M Sequence **/ #include <stdio.h> #include <malloc.h> #include <algorithm> using namespace std; int main(){ int n; scanf("%d",&n); //array of sequences int* arr = (int*)malloc(sizeof(int)*n); for(int i=0;i<n;i++){ scanf("%d",&arr[i]); } printf("%d", (*max_element(arr,arr+n) - *min_element(arr,arr+n))*n); } ``` 广告位招租 Last modification:April 5th, 2022 at 02:34 pm © 允许规范转载 Support 如果觉得我的文章对你有用,请随意赞赏 Appreciate the author 支付宝微信
3 comments
大佬有兴趣简单写下题解吗
我懒