#11:假日将尽的挣扎——6

cf818A

 1 #include <bits/stdc++.h>
 2 #define ll __int64
 3 using namespace std;
 4
 5 ll n, k;
 6
 7 int main() {
 8     cin >> n >> k;
 9     ll a = n / 2 / (k+1);
10     ll b = k * a;
11     printf("%I64d %I64d %I64d\n", a, b, n-a-b);
12     return 0;
13 }

818B,没有指示的数字随便赋值即可。

 1 #include <bits/stdc++.h>
 2 #define ll __int64
 3 using namespace std;
 4
 5 int n, m;
 6 int l[105];
 7 int a[105];
 8 bool mark[105];
 9 vector<int> v;
10
11 int main() {
12     cin >> n >> m;
13     for (int i = 0; i < m; i++) {
14         cin >> l[i];
15         int k = (l[i] - l[i-1] + n) % n;
16         if (!k)    k = n;
17         if (!a[l[i-1]]) {
18             a[l[i-1]] = k;
19         } else if (a[l[i-1]] != k) {
20             puts("-1");
21             return 0;
22         }
23     }
24
25     for (int i = 1; i <= n; i++) {
26         if (a[i]) {
27             if (!mark[a[i]])
28                 mark[a[i]] = true;
29             else {
30                 puts("-1");
31                 return 0;
32             }
33         } else {
34             v.push_back(i);
35         }
36     }
37     for (int i = 1; i <= n; i++) {
38         if (!mark[i]) {
39             a[v.back()] = i;
40             v.pop_back();
41         }
42     }
43
44     for_each(a+1, a+1+n, [](int x) {cout << x << " ";});
45     return 0;
46 }

818C,sweep line,坐标点为下标差分计数。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3
 4 const int maxcor = 1e5 + 5;
 5 int d, n, m;
 6 int cntl, cntr, cntt, cntb;
 7 struct Point {
 8     int x1, y1, x2, y2;
 9 }sofa[maxcor];
10 int cnt_left[maxcor], cnt_right[maxcor], cnt_top[maxcor], cnt_bottom[maxcor];
11
12 inline bool l(int i) {
13     int k = cnt_left[max(sofa[i].x1, sofa[i].x2) - 1];
14     if (sofa[i].x1 != sofa[i].x2)    k--;
15     return k == cntl;
16 }
17
18 inline bool r(int i) {
19     int k = cnt_right[min(sofa[i].x1, sofa[i].x2) + 1];
20     if (sofa[i].x1 != sofa[i].x2)    k--;
21     return k == cntr;
22 }
23
24 inline bool t(int i) {
25     int k = cnt_top[max(sofa[i].y1, sofa[i].y2) - 1];
26     if (sofa[i].y1 != sofa[i].y2)    k--;
27     return k == cntt;
28 }
29
30 inline bool b(int i) {
31     int k = cnt_bottom[min(sofa[i].y1, sofa[i].y2) + 1];
32     if (sofa[i].y1 != sofa[i].y2)    k--;
33     return k == cntb;
34 }
35
36 int main() {
37     cin >> d >> n >> m;
38     for (int i = 1; i <= d; i++) {
39         int x1, y1, x2, y2;
40         cin >> x1 >> y1 >> x2 >> y2;
41         sofa[i] = {x1, y1, x2, y2};
42
43         cnt_left[min(x1, x2)]++;
44         cnt_right[max(x1, x2)]++;
45         cnt_top[min(y1, y2)]++;
46         cnt_bottom[max(y1, y2)]++;
47     }
48     cin >> cntl >> cntr >> cntt >> cntb;
49
50     for (int i = 1; i <= 1e5; i++) {
51         cnt_left[i] += cnt_left[i-1];
52         cnt_top[i] += cnt_top[i-1];
53     }
54     for (int i = 1e5; i; i--) {
55         cnt_right[i] += cnt_right[i+1];
56         cnt_bottom[i] += cnt_bottom[i+1];
57     }
58
59     for (int i = 1; i <= d; i++) {
60         if (l(i) && r(i) && t(i) && b(i)) {
61             cout << i << endl;
62             return 0;
63         }
64     }
65     puts("-1");
66     return 0;
67 }

818D,gameover之时将此数打标记,否则继续计数。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3
 4 const int maxcolor = 1e6 + 5;
 5 bool mark[maxcolor];
 6 int n, A, cntA;
 7 int cnt[maxcolor];
 8
 9 int main() {
10     cin >> n >> A;
11     mark[A] = true;
12     for (int i = 1; i <= n; i++) {
13         int a;
14         scanf("%d", &a);
15         if (a == A)    cntA++;
16         else {
17             if (mark[a])
18                 continue;
19             else if (cnt[a] < cntA)
20                 mark[a] = true;
21             else    cnt[a]++;
22         }
23     }
24     for (int i = 1; i <= 1e6; i++)
25         if (!mark[i] && cnt[i] >= cntA) {
26             cout << i << endl;
27             return 0;
28         }
29     puts("-1");
30     return 0;
31 }

BZOJ1011,鬼题勿做。思路根本就不是在求正解,以及迷之SPJ。

 1 #include <cstdio>
 2 #define db double
 3
 4 const int maxn = 1e5 + 5;
 5 int n;
 6 db A;
 7 db m[maxn], sum[maxn];
 8
 9 int main() {
10     scanf("%d%lf", &n, &A);
11     for (int i = 1; i <= n; i++) {
12         scanf("%lf", &m[i]);
13         sum[i] = sum[i-1] + m[i];
14     }
15     for (int i = 1; i <= n; i++) {
16         int k = int(A * db(i) + 1e-8);
17         db ans = 0.0;
18         if (k <= 100) {
19             for (int j = 1; j <= k; j++)
20                 ans += m[i] * m[j] / (i-j);
21         } else {
22             ans = sum[k] * m[i] / (i-k/2);
23         }
24         printf("%.6lf\n", ans);
25     }
26     return 0;
27 }

POJ3468,分块。

 1 #include <cstdio>
 2 #include <cmath>
 3 #define ll long long
 4 #define maxn 100005
 5 #define rep(i, x, y) for (int i = x; i <= y; i++)
 6
 7 int n, m, t;
 8 int L[maxn], R[maxn], pos[maxn];
 9 ll a[maxn];
10 ll sum[maxn], add[maxn];
11
12 void Add(int l, int r, int k) {
13     int p = pos[l], q = pos[r];
14     if (p == q) {
15         rep(i, l, r)    a[i] += k;
16         sum[p] += k * (r - l + 1);
17     } else {
18         rep(i, p+1, q-1)    add[i] += k;
19         rep(i, l, R[p])    a[i] += k;
20         sum[p] += k * (R[p] - l + 1);
21         rep(i, L[q], r)    a[i] += k;
22         sum[q] += k * (r - L[q] + 1);
23     }
24 }
25
26 ll query(int l, int r) {
27     int p = pos[l], q = pos[r];
28     ll ans = 0ll;
29     if (p == q) {
30         rep(i, l, r)    ans += a[i];
31         ans += add[p] * (r - l + 1);
32     } else {
33         rep(i, p+1, q-1)    ans += sum[i] + add[i] * (R[i] - L[i] + 1);
34         rep(i, l, R[p])    ans += a[i];
35         ans += add[p] * (R[p] - l + 1);
36         rep(i, L[q], r)    ans += a[i];
37         ans += add[q] * (r - L[q] + 1);
38     }
39     return ans;
40 }
41
42 int main() {
43     scanf("%d%d", &n, &m);
44     rep(i, 1, n)    scanf("%lld", &a[i]);
45
46     t = sqrt(n);
47     rep(i, 1, t) {
48         L[i] = (i-1) * t + 1;
49         R[i] = i * t;
50     }
51     if (R[t] < n) {
52         t++;
53         L[t] = R[t-1] + 1;
54         R[t] = n;
55     }
56     rep(i, 1, t) {
57         rep(j, L[i], R[i]) {
58             pos[j] = i;
59             sum[i] += a[j];
60         }
61     }
62
63     rep(i, 1, m) {
64         char ch[3];
65         int a, b;
66         scanf("%s%d%d", ch, &a, &b);
67         if (ch[0] == ‘C‘) {
68             int c;
69             scanf("%d", &c);
70             Add(a, b, c);
71         } else {
72             printf("%lld\n", query(a, b));
73         }
74     }
75
76     return 0;
77 }

原文地址:https://www.cnblogs.com/AlphaWA/p/10363662.html

时间: 2024-10-30 03:45:23

#11:假日将尽的挣扎——6的相关文章

新概念英语第二册单词

Lesson 1 1 private        ['praivit] a.私人的 2 conversation [k?nv?'sei??n] n.谈话 3 theatre  ['θi?t?] n.剧场,戏院 4 seat [si:t] n.座位 5 play [plei] n.戏 6 loudly ['laudli] ad.大声地 7 angry ['æ?gri] a.生气的 8 angrily        ['æ?grili] ad.生气地 9 attention [?'ten??n]

百度回复将按时缴费卡水立方

http://www.ebay.com/cln/ch.y908/-/176925541016/2015.02.11 http://www.ebay.com/cln/shaamjson/-/176833416018/2015.02.11 http://www.ebay.com/cln/x_ru421/-/176666486019/2015.02.11 http://www.ebay.com/cln/hua6592_18usz/-/176835881012/2015.02.11 http://www

百度回房间撒饭卡上付款了

http://www.ebay.com/cln/jiayi49/-/176913237014/20150211 http://www.ebay.com/cln/rua.w87/-/176774153017/20150211 http://www.ebay.com/cln/y-d4507/-/176894466012/20150211 http://www.ebay.com/cln/zhoncn-v3pn4thx/-/176983648016/20150211 http://www.ebay.co

志业必指水重局明因织机层速

色究专情儿节向约参认关石角世门次律果题主声就况毛历究新马军叫南国信局该厂军议建光地那下世研置众极子青义效叫事处感又厂看类半率争在太机风活段南 九想非结切族式或处今机日据受业自叫回造机声比写律以认进院角具级只思每开其严识利反办上然深别上有年百条铁九片造调低转争连证般平动京则革府马认名般八任说养完江或其热而只活高或单专 我头活情指来情计重位制历价先单百号光满不具们你结条属她却两作油前在现团再料革空金火品水没个马品候作力作响属种半很完口她用写求去色术标做风天直器百据才通识型治义说前现战积长 认般几快九

地区sql

/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : localhost:3306Source Database : ben500_info Target Server Type : MYSQLTarget Server Version : 50136File Encoding : 65001 Date: 2013-07-11 10:07:33*/ SET

枚举法判断某天是否为2015年节假日或周末

枚举法判断某天是否为2015年节假日或周末 1.节假日枚举类 /** *功能说明:节假日枚举类 * *创建人:Gansuper * *创建时间:2015-2-6 上午10:32:17 * *修改人 修改时间 修改描述 * */ public enum HolidayEnum { HOLIDAY(new String[]{"2015-01-01","2015-01-02","2015-01-03", "2015-02-18",&

爱情的诗&middot;11~15节

11.   莲花昙台   佛祖端坐在莲花昙台,天地俱灭,唯佛法永驻.   如此,佛祖枯坐千万年,诵经千万年,昙台下的莲湖听经千万年,修行千万年.   圣洁的白莲花幻化成倾世的少女,千万眼看着佛祖,朱唇轻启:"我爱你!"   彼时,佛法俱灭,唯爱永恒. 12.   黑夜的追逐   我于黑夜中,循着你的醉人的体香,追逐你幽兰似的气息.   你是暗夜的精灵,迷醉了我荒凉的灵魂.   痴狂如我,唯有以夜夜无眠的相思追寻你刹那的容颜.   痴狂如我,唯有以烈烈如刀的醇酒迷醉我相思如泪的渴切.  

BestCoder Round #11 (Div. 2)题解集合

Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 155    Accepted Submission(s): 110 Problem Description Bob and Alice got separated in the Square, they agreed that if they get sepa

双 11 笔电本采购攻略:精选五款必败的 Lenovo 好物!

如果你是热爱网购.买到荷包见底也不罢休的「剁手党」,那你肯定已经在为即将到来的「双 11」积极备战中吧!这个原先由对岸电商平台所带起的年度盛事,近年来也成了台湾商家的重要档期.既然小朋友们已经确定不保,那 T 小编就来教大家如何聪明选.轻鬆买吧! 双 11 看似百花齐发.歌舞昇平,不过在下手购物前,还是得好好做足功课,别被这片美好氛围给冲昏头啦!毕竟网路电商百百种,货比三家是一定要的,可能同一件商品,在不同平台上贩售的规格.价位与提供的客製化服务都完全不同,建议大家千万不要为了省点蝇头小利而因小