1:
#include<stdio.h> #include<stdlib.h> int a[100]; int b[100]; int cmp(const void *a,const void *b) { return *(int *)a - *(int *)b; } void insertion_sort(int a[],int n){ for(int i = 1; i < n; i++){ int temp = a[i]; for(int j = i - 1;j >= 0;j--){ if(a[j] > temp){ a[j + 1] = a[j]; a[j] = temp; } else break; } } } void Bubble_sort(int a[], int n) { int i, j; for (i = 0; i < n - 1; i++){ for (j = 0; j < n - 1 - i; j++){ if (a[j] > a[j + 1]){ int tmp = a[j]; a[j] = a[j + 1]; a[j + 1] = tmp; } } } } int main() { int t; scanf("%d",&t); while(t--){ int n,m; scanf("%d %d",&n,&m); for(int i = 0; i < n; ++i){ scanf("%d",&a[i]); } for(int i = 0; i < m; ++i){ scanf("%d",&b[i]); } qsort(b, m, sizeof(b[0]), cmp); int ans = 10,cnt = 0; for(int i = 0; i < n; ++i){ if(ans < 0){ cnt --; break; } else{ ans -= b[i]; cnt++; } } qsort(a, n, sizeof(a[0]), cmp); for(int i = 0; i < n - 1; ++i){ if(a[i] == a[i + 1]){ a[i] = 0; } } while(cnt--){ int j = 1; for(int i = 0; i < n; ++i){ if(a[i] <= 0)continue; if(a[i] - j == 0){ j += 1; } a[i] -= j; } } int f = 1; for(int i = 0; i < n; ++i){ if(a[i] > 0){ f = 0; break; } } if(f)printf("YES\n"); else printf("NO\n"); } return 0; }
2:
#include<stdio.h> int main() { long long n; long long t; scanf("%lld",&t); while(t--){ scanf("%lld",&n); if(n < 4){ printf("WA\n"); printf("4 6\n"); } else printf("AC\n"); } return 0; }
3:
#include<stdio.h> #include<math.h> char s[10005]; int main() { int T; scanf("%d",&T); while(T--) { int n; int f = 0; scanf("%d", &n); scanf("%s", s); for(int i = 0; i < n;i++){ if(s[i] != s[n - 1 - i] && abs((int)(s[i] - s[n - 1 - i])) != 2){ f = 1; break; } } if(!f)printf("YES\n"); else printf("NO\n"); } return 0; }
4:
#include <bits/stdc++.h> using namespace std; void solve() { int n; scanf("%d",&n); if (n >= 9 && n & 1) puts("YES"); else puts("NO"); } int main() { int t; scanf("%d",&t); while(t--)solve(); }
5:
#include <bits/stdc++.h> using namespace std; void solve() { int n; scanf("%d",&n); if (n >= 9 && n & 1) puts("YES"); else puts("NO"); } int main() { int t; scanf("%d",&t); while(t--)solve(); }
6:
#include<bits/stdc++.h> using namespace std; int n; void solve() { cin >> n; for(int i = 1; i <= n; i ++ ) if(i <= 2) cout << (2 - i + 8) % 10; else cout << (i + 6) % 10; cout << '\n'; } int main() { int T; cin >> T; while(T -- ) solve(); return 0; }
7:
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s = "AABAA"; int cnt = 1; for(int i = 1;i <= 10;i ++){ for(int j = 0;j < 5;j ++){ printf("%c",s[j]); for(int k = 1;k <=cnt; k ++) { printf("\t"); } cnt++; } } }
8:
#include <stdio.h> int main() { int a[10] = {0}, num = 0; for(int i = 0; i < 6; i ++) { scanf("%d",&a[i]); num += a[i]; // 算出6个数字的和 } for(int i = 0; i < 6; i ++) { for(int j = 0; j < 6; j ++) { if(i == j) continue; for(int k = 0; k < 6; k ++) { if(k == i || k == j) continue; int sum = a[i] + a[j] + a[k]; // 选出的3个数的和 if(num - sum == sum) // 判断 { puts("YES"); return 0; } } } } puts("NO"); return 0; }
9:
#include <stdio.h> int pd(int x) //判断一个数是否是完美数 { int num = 0; while(x) { num += x % 10; x /= 10; } if(num == 10) return 1; else return 0; } int main() { int k, c = 1; scanf("%d",&k); int p[100010] = {0}; for(int i = 19; i < 2e7; i ++) { if(pd(i)) p[c++] = i; } printf("%d",p[k]); return 0; }
10:
#include <stdio.h> int main() { int a,b; scanf("%d%d",&a,&b); if(abs(a-b) >= 2 || (a == 0 && b == 0)) puts("NO"); else puts("YES"); return 0; }
11:
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; long long g; cin>>g; for(int i=2;i<=n;i++) { long long t; cin>>t; g=__gcd(t,g); } cout<<g*n; }
标签:main,return,int,scanf,++,考核,include From: https://www.cnblogs.com/ljm-xiada/p/16794195.html