https://ac.nowcoder.com/acm/contest/696#question
A
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; int T; char c[10] = {'N', 'o', 'w', 'C', 'o', 'd', 'e', 'r'}; bool f(string s) { int len = s.length(); int pos = 0; for(int i = 0; i < len; i ++) { if(s[i] == c[pos]) pos ++; } if(pos == 8) return true; return false; } int main() { scanf("%d", &T); while(T --) { string s; cin >> s; if(f(s)) printf("QAK "); else printf("QIE "); } return 0; }
B
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N; long long a[maxn]; int getlen(long long x) { int cnt = 0; if(x == 0) return 1; while(x) { cnt ++; x /= 2; } return cnt; } int BitCount2(long long n) { int c = 0; for(c =0; n; ++ c) n &= (n - 1); return c ; } int sum(long long x) { int a = getlen(x); int b = BitCount2(x); if(b * 2 > a) return 1; return -1; } int main() { scanf("%d", &N); long long ans = 0; for(int i = 0; i < N; i ++) { scanf("%lld", &a[i]); a[i] = abs(a[i]); ans += sum(a[i]); } printf("%lld ", ans); return 0; }
C
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int N; long long Pow(long long a, long long b) { long long ans1 = 1; a = a % mod; while(b) { if(b % 2) { ans1 = (ans1 * a) % mod; b --; } else { a = (a * a) % mod; b /= 2; } } return ans1; } int main() { scanf("%d", &N); long long ans = 0; if(N < 3) ans = Pow(26, N); else ans = 3 * Pow(25, N) - 3 * Pow(24, N) + Pow(23, N); ans = (ans % mod + mod) % mod; printf("%lld ", ans % mod); return 0; }