A
暴力即可。
多想一秒其他的都是对5这个数字的不尊重。
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 #include <bits/stdc++.h> using namespace std;using ll=long long ;#define int long long const int N=1e6 +100 ;ll val[N]; const ll mod=1e9 +7 ;uniform_int_distribution<int > qwq (1 , 400000000000000000 ) ;mt19937_64 mt; void solve () {int a,b,c; cin>>a>>b>>c; int ans=a*b*c; for (int i=0 ;i<=5 ;i++) { for (int j=0 ;j+i<=5 ;j++) { for (int k=0 ;i+j+k<=5 ;k++) { ans=max (ans,(a+i)*(b+j)*(c+k)); } } } cout<<ans<<'\n' ; } signed main () { int t; cin>>t; while (t--) { solve (); } }
B
观察:可以得到一定会留下最大的数字。其他的一定会变成1。
这时候直接排序即可。
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 #include <bits/stdc++.h> using namespace std;using ll=long long ;#define int long long const int N=1e6 +100 ;ll val[N]; const ll mod=1e9 +7 ;uniform_int_distribution<int > qwq (1 , 400000000000000000 ) ;mt19937_64 mt; int a[N];void solve () {int n;cin>>n; int k;cin>>k; int maxn=0 ;int ans=0 ;for (int i=1 ;i<=k;i++){ cin>>a[i]; } sort (a+1 ,a+1 +k);for (int i=1 ;i<=k-1 ;i++){ ans+=a[i]-1 ; } cout<<ans+n-a[k]<<'\n' ; } signed main () { int t; cin>>t; while (t--) { solve (); } }
C
构造题目:
阅读题意,先构造k,从大到小
然后构造m,从小到大
之后取得一个最小的直接枚举结束即可。
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 #include <bits/stdc++.h> using namespace std;using ll=long long ;#define int long long const int N=1e6 +100 ;ll val[N]; const ll mod=1e9 +7 ;uniform_int_distribution<int > qwq (1 , 400000000000000000 ) ;mt19937_64 mt; int a[N];void solve () {int n,m,k;cin>>n>>m>>k; for (int i=n;i>=k;i--){ cout<<i<<' ' ; } for (int i=m+1 ;i<k;i++){ cout<<i<<' ' ; } for (int i=1 ;i<min (m+1 ,k);i++){ cout<<i<<' ' ; } cout<<'\n' ; } signed main () { int t; cin>>t; while (t--) { solve (); } }
D
如果可以跳到下一个平台那么一定要跳。
如果不能一定要跳满。
期间可以进行一个判NO操作。
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 #include <bits/stdc++.h> using namespace std;using ll=long long ;#define int long long const int N=1e6 +100 ;ll val[N]; const ll mod=1e9 +7 ;uniform_int_distribution<int > qwq (1 , 400000000000000000 ) ;mt19937_64 mt; int a[N];void solve () { int n , m , k; cin >> n >> m >> k; string s; cin >> s; int ans = 0 ; int l = 0 ; s = 'L' + s; for (int i = 0 ; i <= n ;) { if (s[i] == 'L' ) { int l = i + m; i++; while (i <= n && i < l) { if (s[i] != 'L' ) i++; else break ; } if (s[i] == 'C' ) { cout << "NO" << '\n' ; return ; } } else if (s[i] == 'W' ) { ans++; i++; } else { cout << "NO" << '\n' ; return ; } } if (ans <= k) cout << "YES" << '\n' ; else cout << "NO" << '\n' ; } signed main () { int t; cin>>t; while (t--) { solve (); } }
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 40 41 42 43 44 45 46 47 48 49 50 51 52 #include <bits/stdc++.h> using namespace std;int t, n;int cnt[110 ];vector<pair<int , int >> zu[110 ]; void init () { for (int i = 1 ; i <= 100 ; i++) { string ck; for (int k = 1 ; k <= 7 ; k++) { if (k == 1 ) ck = to_string (i); else ck += ck; } for (int a = 1 ; a <= 10000 ; a++) { for (int k = 1 ; k <= 6 ; k++) { int ans = stoi (ck.substr (0 , k)); int b = i * a - ans; if (b < 1 || b > 10000 || b > i * a) continue ; if (i >= 10 ) { if (2 * a - b != k) continue ; } else { if (a - b != k) continue ; } cnt[i]++; zu[i].push_back ({a, b}); } } } } int main () { init (); cin >> t; while (t--) { cin >> n; cout << cnt[n] << endl; for (int i = 0 ; i < zu[n].size (); i++) { cout << zu[n][i].first << " " << zu[n][i].second << endl; } } return 0 ; }
F
技巧1:如果不能被x整除,那么这个数字毫无意义
技巧2:a[i]
如果可以被整除,那么我们要暴力枚举之前的所有段落是否出现过x/a[i]
,这个过程可以用哈希表进行判断
技巧3:a[i]
这个数字对之前的分段有影响,因此在哈希表中暴力给每个数字×上这个数字即可
综上即可AC。
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 #include <bits/stdc++.h> #define int long long using namespace std;const int N = 2e5 + 10 ;int a[N];void solve () { int n , x; cin >> n >> x; for (int i = 1 ; i <= n ; i++) cin >> a[i]; int ans = 1 ; unordered_map<int , int > mp; for (int i = 1 ; i <= n ; i++) { if (x % a[i] == 0 ) { if (mp[x / a[i]] > 0 ) { ans++; i--; mp.clear (); } else { vector<int > res; for (auto p : mp) { if (p.second == 0 ) continue ; if (p.first * a[i] > x) continue ; res.push_back (p.first * a[i]); } mp[a[i]]++; for (auto p : res) mp[p]++; res.clear (); } } } cout << ans << endl; } signed main () { int t; cin >> t; while (t--) solve (); return 0 ; }