比赛地址:校园网访问Contest Detail - XAUT OJ
本大二老蒟蒻的第一篇题解,如有错误或表述不当之处请联系QQ3488643420,请多多包涵!
本次校内新生赛,俺老黄瓜刷绿漆,与各级各院高手同台竞技,不胜荣幸!
前六题基本上是语法题,难度不大,没用到什么复杂的算法。
最后一个多小时对着G坐牢太过难受,还是要多多提升自己,不然就要被后浪狠狠拍在沙滩上了T^T。
D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
   | #include <bits/stdc++.h> #define fast                          \     std::ios::sync_with_stdio(false); \     std::cin.tie(nullptr); using namespace std; typedef long long ll; ll l,r,ans; int main() {     fast;     ans=0;     cin>>l>>r;     if(l<=2) l=3;     if(l%2==0) l--;     if(r%2==0) r++;     ans=(r-l)/2;               if(r<=2) ans=0;     cout<<ans;     return 0; }
 
   | 
 
本题与哥德巴赫猜想有关,任何大于2的偶数都能够写成两个质数相加的形式,虽然尚未被证明,但也没被证伪,我们可以运用该猜想。
要注意特判一下范围是否包括2,l、r都要特判。(本蒟蒻没判断r,WA了好几发QAQ)
E
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
   | #include <bits/stdc++.h> #define fast                          \     std::ios::sync_with_stdio(false); \     std::cin.tie(nullptr); using namespace std; typedef long long ll; const int N = 1e6 + 10; int n; void solve() {     cin >> n;     if (n <= 6)     {         cout << "NO\n";         return;     }     n -= 1;     int x = 2;     while (!(x % 3 && (n - x) % 3))     {         x++;         if (x == n - x||n-x==1)         {             cout << "NO\n";             return;         }     }     cout << "YES\n"          << 1 << ' ' << x << ' ' << n - x << '\n'; } int main() {     fast;     int _ = 1;     cin >> _;     while (_--)         solve();     return 0; }
   | 
 
注意三个数不能相同
F
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
   | #include <bits/stdc++.h> #define fast                          \     std::ios::sync_with_stdio(false); \     std::cin.tie(nullptr); using namespace std; typedef long long ll; const int N = 1e6 + 10; int n,k; string s; void solve() {     string t;     cin >> t;     int len = t.size();     if(len>s.size())     {         cout<<"NO\n";         return;     }         for (int i = 0; i < s.size(); i++)         {             if (s[i] != t[i % len])             {                 cout << "NO\n";                 return;             }         }     cout << "YES\n"; } int main() {     fast;     cin>>n>>k;     cin>>s;     while (k--)     {         solve();     }          return 0; }
 
   | 
 
无回溯的子串匹配,用不到KMP
注意特判一下t的长度大于s的情况。
G
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
   | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  | 
 
史山也贴出来吧,毕竟也做了一个多小时(虽然是无用功)
做出来俩种方法,一种超时间限制,一种超空间限制。
应该继续考虑优化存储方式,减少空间占用。