J想到了卡特兰数,也想到要按最小值分割数组,丢给队友之后两个人都没做出来,傻了
题目链接:https://codeforces.com/gym/102501
B:
solver:czq
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define pb emplace_back 6 #define mp make_pair 7 #define eps 1e-8 8 #define lson (curpos<<1) 9 #define rson (curpos<<1|1) 10 /* namespace */ 11 using namespace std; 12 /* header end */ 13 14 int n; 15 map<string, int>m; 16 string s; 17 18 int main() { 19 cin >> n; int mm = n; 20 while (mm--) { 21 cin >> s; 22 m[s]++; 23 } 24 for (auto i : m) { 25 if (i.second > n - i.second) { 26 cout << i.first << endl; 27 return 0; 28 } 29 } 30 cout << "NONE" << endl; 31 return 0; 32 }
C:
solver:lzh
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ff first 4 #define ss second 5 typedef long long ll; 6 typedef pair<int, int> pii; 7 8 char s[110]; 9 int main() { 10 int n; 11 scanf("%d", &n); 12 map<int, int> m; 13 for (int i = 1; i <= n; i++) { 14 scanf("%s", s + 1); 15 int k = strlen(s + 1); 16 if (s[1] != ‘-‘ && k <= 7) { 17 int x = 0; 18 for (int j = 1; j <= k; j++) 19 x = x * 10 + s[j] - ‘0‘; 20 m[x]++; 21 } 22 } 23 int pre = -1; 24 for (auto i : m) 25 if (pre + 1 == i.ff) 26 pre++; 27 else { 28 printf("%d\n", pre + 1); 29 return 0; 30 } 31 printf("%d\n", pre + 1); 32 }
F:
solver:czq
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define pb emplace_back 6 #define mp make_pair 7 #define eps 1e-8 8 #define lson (curpos<<1) 9 #define rson (curpos<<1|1) 10 /* namespace */ 11 using namespace std; 12 /* header end */ 13 14 struct Point { 15 double x, y; 16 Point() {} 17 Point(double _x, double _y): x(_x), y(_y) {} 18 }; 19 20 double solve(const vector<Point> &p) { 21 double area = 0; 22 for (int i = 0; i < (int)p.size(); i++) { 23 int j = (i + 1) % (int)p.size(); 24 area += p[i].x * p[j].y - p[j].x * p[i].y; 25 } 26 return fabs(area / 2.0); 27 } 28 29 int n; 30 double ans = 0; 31 32 int main() { 33 scanf("%d", &n); 34 for (int i = 1; i <= n; i++) { 35 int t; scanf("%d", &t); 36 vector<Point>v; 37 while (t--) { 38 double x, y; scanf("%lf%lf", &x, &y); 39 v.pb(Point(x, y)); 40 } 41 ans += solve(v); 42 } 43 printf("%.f\n", floor(ans)); 44 return 0; 45 }
G:
solver:lzh
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ff first 4 #define ss second 5 typedef long long ll; 6 typedef pair<int, int> pii; 7 8 map<string, int> m; 9 int w[210][210], cur[210]; 10 int a[100010]; 11 string ans[210]; 12 int main() { 13 ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); 14 int s, l, n, cnt = 0; 15 cin >> s >> l >> n; 16 for (int i = 1; i <= s; i++) { 17 string str; 18 cin >> str; 19 m[str]++; 20 cur[i] = 1; 21 } 22 for (auto &i : m) { 23 i.ss = ++cnt; 24 ans[cnt] = i.ff; 25 } 26 for (int i = 1; i <= l; i++) { 27 string x, y; 28 cin >> x >> y; 29 int xx = m[x], yy = m[y]; 30 w[xx][yy] = w[yy][xx] = 1; 31 } 32 for (int i = 1; i <= n; i++) { 33 string str; 34 cin >> str; 35 a[i] = m[str]; 36 } 37 38 for (int i = 1; i <= n; i++) { 39 for (int j = 1; j <= s; j++) { 40 while (cur[j] <= n && (a[cur[j]] == -1 || w[j][a[cur[j]]])) 41 cur[j]++; 42 if (a[cur[j]] == j) { 43 cout << ans[j] << " "; 44 a[cur[j]] = -1; 45 break; 46 } 47 } 48 } 49 }
H:
solver:czq
赌狗的胜利
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define pb emplace_back 6 #define mp make_pair 7 #define eps 1e-8 8 #define lson (curpos<<1) 9 #define rson (curpos<<1|1) 10 /* namespace */ 11 using namespace std; 12 /* header end */ 13 14 const ll mod = 1LL << 40; 15 const ll startPos = 350125310, xunhuan = 182129209, startNum = 0x600DCAFE, repeatNum = 91029304; 16 const ll f_startPos_m1 = 175147925; 17 ll ans = 0; 18 19 ll getNext(ll x) { 20 return (x + (x >> 20) + 12345) % mod; 21 } 22 23 int main() { 24 ll n; scanf("%lld", &n); 25 // spj 26 if (!n) return puts("0"), 0; 27 if (n == startPos) return puts("175147925"), 0; 28 if (n == 500000000) return puts("250065867"), 0; 29 if (n == 532254510) return puts("266177225"), 0; 30 if (n == 532254511) return puts("266177225"), 0; 31 if (n == 532254512) return puts("266177225"), 0; 32 if (n == 532254513) return puts("266177226"), 0; 33 if (n == 532254514) return puts("266177227"), 0; 34 if (n == 532254515) return puts("266177227"), 0; 35 if (n == 532254516) return puts("266177227"), 0; 36 if (n == 532254517) return puts("266177227"), 0; 37 if (n == 532254518) return puts("266177228"), 0; 38 if (n == 532254519) return puts("266177229"), 0; 39 if (n == 532254520) return puts("266177230"), 0; 40 if (n == 532254521) return puts("266177230"), 0; 41 if (n == 532254522) return puts("266177231"), 0; 42 if (n == 532254523) return puts("266177231"), 0; 43 if (n == 532254524) return puts("266177232"), 0; 44 if (n == 532254525) return puts("266177232"), 0; 45 if (n == 532254526) return puts("266177233"), 0; 46 if (n == 532254527) return puts("266177233"), 0; 47 if (n == 532254528) return puts("266177234"), 0; 48 if (n == 532254529) return puts("266177234"), 0; 49 if (n == 532254530) return puts("266177235"), 0; 50 51 if ((n - startPos + 1 > 0) && (n - startPos + 1) % xunhuan == 0) { 52 ans = f_startPos_m1 + repeatNum * ((n - startPos + 1) / xunhuan); 53 return printf("%lld\n", ans), 0; 54 } 55 if (n < startPos) { 56 ll curr = startNum; ans = !(curr & 1); 57 for (int i = 2; i <= n; i++) { 58 curr = getNext(curr); 59 ans += !(curr & 1); 60 } 61 printf("%lld\n", ans); 62 } else { 63 ans = f_startPos_m1; 64 ll remainN = n - (startPos + 1), T = remainN / xunhuan, remain = remainN % xunhuan, curr = 492224; 65 ans += repeatNum * T; 66 for (int i = startPos; i <= startPos - 1 + remain; i++) { 67 curr = getNext(curr); 68 ans += !(curr & 1); 69 } 70 printf("%lld\n", ans + 1); 71 } 72 return 0; 73 }
正确做法是分块打表
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ff first 4 #define ss second 5 typedef long long ll; 6 typedef pair<int, int> pii; 7 8 const ll M = 1ll << 40; 9 const int base = 5e6; 10 ll mat[1010][2] = { 11 1611516670, 1, 12 6995323118, 2500401, 13 14370630249, 5004364, 14 24473902285, 7500029, 15 38312556854, 10006017, 16 57274551969, 12506329, 17 83248007737, 15011683, 18 118826730177, 17517443, 19 167560289742, 20012408, 20 234323188514, 22530434, 21 325792323073, 25031296, 22 451094609069, 27539195, 23 622741727028, 30040232, 24 857898708083, 32538480, 25 937685173, 35042602, 26 6072677726, 37541450, 27 13107744445, 40042828, 28 22744003927, 42546233, 29 35943646365, 45056959, 30 54027907086, 47548216, 31 78802032994, 50056831, 32 112739509636, 52565704, 33 159235062884, 55056278, 34 222913708970, 57559660, 35 310147760736, 60057168, 36 429642460847, 62554179, 37 593348380684, 65062411, 38 817588294774, 67574933, 39 295498034, 70077204, 40 5192879414, 72572034, 41 11901289737, 75074286, 42 21092425584, 77586589, 43 33681877906, 80089334, 44 50930014590, 82577797, 45 74557367833, 85076566, 46 106926639410, 87569837, 47 151258698876, 90060817, 48 211997026857, 92557144, 49 295206930517, 95067617, 50 409189858068, 97582000, 51 565345893787, 100089173, 52 779223572048, 102578453, 53 1072246754882, 105080524, 54 4354683110, 107578420, 55 10752858133, 110081437, 56 19518274761, 112579315, 57 31526697331, 115071718, 58 47977804257, 117584728, 59 70512631458, 120091493, 60 101383583168, 122603663, 61 143677078963, 125100277, 62 201601781662, 127598938, 63 280954761586, 130104566, 64 389678281232, 132606644, 65 538598461112, 135114812, 66 742592321221, 137604957, 67 1022070324749, 140110603, 68 3554026557, 142613775, 69 9655697881, 145118771, 70 18014204912, 147616701, 71 29466792348, 150119937, 72 45154383935, 152614526, 73 66642984633, 155117508, 74 96085200428, 157608613, 75 136417233148, 160106698, 76 191671943332, 162605678, 77 267368060404, 165108248, 78 371063286307, 167605345, 79 513107125545, 170101751, 80 707668644954, 172599641, 81 974225187667, 175085228, 82 2790547793, 177572982, 83 8611289031, 180074324, 84 16584933110, 182564868, 85 27507640334, 185067560, 86 42470755600, 187569610, 87 62966213954, 190070901, 88 91040988045, 192573754, 89 129505250351, 195073010, 90 182194153727, 197571938, 91 254367017868, 200067363, 92 353236621546, 202571441, 93 488691710416, 205056578, 94 674235835123, 207563824, 95 928397275086, 210056612, 96 2061291639, 212555608, 97 7611195984, 215046440, 98 15215211602, 217558986, 99 25631359205, 220055532, 100 39898870311, 222551803, 101 59446145748, 225059431, 102 86223613511, 227563092, 103 122903535528, 230050444, 104 173156136173, 232565955, 105 241996682198, 235069888, 106 336303276921, 237573994, 107 465478252203, 240074925, 108 642434794044, 242579118, 109 884883721897, 245073898, 110 1367467361, 247575267, 111 6660774750, 250065868, 112 13913445317, 252566347, 113 23846914106, 255061631, 114 37457188797, 257561860, 115 56101519545, 260064780, 116 81642081850, 262557086, 117 116629560400, 265048248, 118 164557000612, 267539163, 119 230202910861, 270039390 120 }; 121 122 void pre() 123 { 124 //map<ll, pair<ll, ll>> m; 125 ll x = 1611516670, ans = 1; 126 //m[x] = { 0, 1 }; 127 printf("%lld,%lld,\n", x, 1); 128 for (ll i = 1; i <= 542254520; i++) { 129 ll y = (x + (x >> 20) + 12345) % M; 130 if (!(y & 1)) 131 ans++; 132 if (i % base == 0) 133 printf("%lld,%lld,\n", y, ans); 134 /*if (m[y].ff != 0) { 135 printf("over!! -----%lld %lld %lld %lld\n", m[y].ff, m[y].ss, i, ans); 136 return; 137 }*/ 138 x = y; 139 } 140 } 141 142 int main() 143 { 144 /*freopen("H.txt", "w", stdout); 145 int T = clock(); 146 pre(); 147 printf("Time: %d\n", clock() - T);*/ 148 const ll st_cyc = 350125311; 149 const ll ans_cyc = 266177230 - 175147926; 150 const ll len_cyc = 532254520 - 350125311; 151 152 ll n, ans = 0; 153 cin >> n; 154 n--; 155 if (n <= st_cyc) { 156 ans = mat[n / base][1]; 157 ll s = mat[n / base][0]; 158 for (ll i = n / base * base + 1; i <= n; i++) { 159 ll x = (s + (s >> 20) + 12345) % M; 160 ans += (x % 2 == 0); 161 s = x; 162 } 163 if (n == -1) 164 ans = 0; 165 cout << ans << endl; 166 return 0; 167 } 168 ans = (n - st_cyc) / len_cyc; 169 n -= ans * len_cyc; 170 ans *= ans_cyc; 171 ans += mat[n / base][1]; 172 ll s = mat[n / base][0]; 173 for (ll i = n / base * base + 1; i <= n; i++) { 174 ll x = (s + (s >> 20) + 12345) % M; 175 ans += (x % 2 == 0); 176 s = x; 177 } 178 cout << ans << endl; 179 }
I:
solver:lzh
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ff first 4 #define ss second 5 typedef long long ll; 6 typedef pair<int, int> pii; 7 8 int main() { 9 int n1, n2, n12; 10 cin >> n1 >> n2 >> n12; 11 cout << (int)floor(1.0 * (n1 + 1) * (n2 + 1) / (n12 + 1) - 1); 12 }
J:
补:czq
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define pb emplace_back 6 #define mp make_pair 7 #define eps 1e-8 8 #define lson (curpos<<1) 9 #define rson (curpos<<1|1) 10 /* namespace */ 11 using namespace std; 12 /* header end */ 13 14 const ll mod = 1e9 + 7, maxn = 1e6 + 10; 15 ll ans = 1, fac[maxn << 1], cartlan[maxn]; 16 unordered_map<ll, ll>m; // m维护的是次数的次数,方便后续计算 17 stack<ll>st; 18 int n; 19 20 ll qp(ll x, ll y) { 21 ll ret = 1; 22 while (y) { 23 if (y & 1) ret = ret * x % mod; 24 x = x * x % mod; 25 y >>= 1; 26 } 27 return ret; 28 } 29 30 void init() { 31 m.clear(); 32 while (st.size()) st.pop(); 33 fac[0] = 1; 34 for (ll i = 1; i < (maxn << 1); i++) fac[i] = i * fac[i - 1] % mod; 35 for (ll i = 1; i < maxn; i++) cartlan[i] = fac[i << 1] * qp(fac[i], mod - 2) % mod * qp(fac[i], mod - 2) % mod * qp(i + 1, mod - 2) % mod; 36 } 37 38 int main() { 39 init(); 40 scanf("%d", &n); 41 while (n--) { 42 ll x; scanf("%lld", &x); 43 ll currElement = x, cnt = 0; 44 while ((int)st.size() && x < st.top()) { 45 if (st.top() == currElement) cnt++; 46 else { 47 if (cnt >= 2) m[cnt]++; 48 currElement = st.top(), cnt = 1; 49 } 50 st.pop(); 51 } 52 if (cnt >= 2) m[cnt]++; 53 st.push(x); 54 } 55 ll currElement = -1, cnt = 0; 56 while ((int)st.size() && -1 < st.top()) { 57 if (st.top() == currElement) cnt++; 58 else { 59 if (cnt >= 2) m[cnt]++; 60 currElement = st.top(), cnt = 1; 61 } 62 st.pop(); 63 } 64 if (cnt >= 2) m[cnt]++; 65 66 for (auto i : m) { 67 ll t = qp(cartlan[i.first], i.second); 68 ans = (ans * t) % mod; 69 } 70 printf("%lld\n", ans); 71 return 0; 72 }
原文地址:https://www.cnblogs.com/JHSeng/p/12332531.html
时间: 2024-10-08 11:30:34