2021寒假训练(九)
| 题号 | A | B | C | D | E | F | G |
| AC | √ | Ο | √ |
#include <string.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdexcept> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 1e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1000000007; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } signed main(){ int n; while(~scanf("%lld",&n)){ int res = fastPower(2, n); printf("%lld\n",res * (n % mod - 1) % mod + 1); } //system("pause"); return 0; }
#include <string.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdexcept> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1000000007; // #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } int dp[maxn], cnt[maxn], a[maxn]; signed main(){ int T = rd(); while(T--){ mem(dp, 0); mem(cnt, 0); int n = rd(); for(int i = 0; i < n; i++){ a[i] = rd(); cnt[a[i]]++; } sort(a, a + n); int pre = 0; for(int i = 0; i < n; i++){ if(pre == a[i])continue; else pre = a[i]; dp[a[i]] += cnt[a[i]]; for(int j = a[i] + a[i]; j <= maxn; j += a[i]){ dp[j] = max(dp[j], dp[a[i]]); } } int ans = 0; for(int i = 0; i < maxn; i++){ ans = max(ans, dp[i]); } printf("%lld\n", n - ans); } //system("pause"); return 0; }
#include <string.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdexcept> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 1e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1e9 + 7; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } signed main(){ int T = rd(); while(T--){ int n = rd(); int l = -1; int r = 1e9 + 10; int prex = 0, prey = 0; for(int i = 0; i < n; i++){ int x = rd(); int y = rd(); if(x > l) l = x; if(y < r) r = y; } if(n == 1){ printf("0\n"); continue; } printf("%lld\n",max(0 * 1ll, l - r)); } //system("pause"); return 0; }

浙公网安备 33010602011771号