HZNU 2019 Summer training 8

A - Petya and Origami

CodeForces - 1080A

题意:制造一份邀请函需要2份a物品,5份b物品,8份c物品,一个盒子里面有k份物品(可以为a或b或c)问你制造n份邀请函需要用多少个盒子

题解:加起来就行了

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include<stack>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;

const int maxn = 4e4 + 10;
const int mod = 1e9 + 7;

int main()
{
    int n,k;
    cin >> n >> k;
    int sum = 0;
    sum += ceil(2.0 * n / (k * 1.0));
    sum += ceil(5.0 * n / (k * 1.0));
    sum += ceil(8.0 * n / (k * 1.0));
    cout << sum << endl;
}

B - Margarite and the best present

CodeForces - 1080B

题意:区间内偶数和减去奇数和

题解:分类一下就好了

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include<stack>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;

const int maxn = 4e4 + 10;
const int mod = 1e9 + 7;

int main()
{

    int t;
    cin >> t;
    while (t--)
    {
        ll l, r;
        cin >> l >> r;
        ll ans;
        if (l == r)
        {
            if (l % 2 == 0)
                ans = l;
            else
                ans = -1 * l;
        }
        else
        {
            if (l % 2 == 1 && r % 2 == 1)
                ans = (r - l) / 2 - r;
            else if (l % 2 == 1 && r % 2 == 0)
                ans = (r - l + 1) / 2;
            else if (l % 2 == 0 && r % 2 == 0)
                ans = -1*(r - l) / 2 + r;
            else
                ans = ((r - l + 1) / 2) * (-1);
        }
        cout << ans << endl;

    }

}

C - Masha and two friends

CodeForces - 1080C

题意:给你一个n行m列的黑白块相间的棋盘,进行两次操作,第一次把(x1,y1)到(x2,y2)的区域全部涂白,第二次把(x3,y3)到(x4,y4)的区域全部涂黑,问你这样以后黑白各有多少块?

题解:分割矩形,判断矩形的左下角的点是黑色还是白色就好了

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include<stack>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;

const int maxn = 4e4 + 10;
const int mod = 1e9 + 7;

LL n,m,black,white;
int X1,X2,X3,X4,Y1,Y2,Y3,Y4;

void jishu(LL lx,LL ly,LL rx,LL ry,bool flag) {
    LL N = ry - ly + 1, M = rx - lx + 1, b, w;
    LL tmp = N * M / 2;
    LL res = N * M - tmp;

    if((lx + ly) % 2) {
        w = tmp;
        b = res;
    }
    else {
        b = tmp;
        w = res;
    }

    if(flag) {
        white += b;
        black -= b;
    }
    else {
        black += w;
        white -= w;
    }
}

void cut(LL x1,LL y1,LL x2,LL y2)
{
    if(x1 > x2 || y1 > y2)
        return;
    if(x2<X3 || y2<Y3 || x1>X4 || y1>Y4)
    {
        jishu(x1,y1,x2,y2,1);
        return;
    }
    if(x1<X3) {
        cut(x1, y1, X3 - 1, y2);
        x1 = X3;
    }
    if(x2>X4) {
        cut(X4 + 1, y1, x2, y2);
        x2 = X4;
    }
    if(y1<Y3) {
        cut(x1, y1, x2, Y3 - 1);
        y1 = Y3;
    }
    if(y2>Y4) {
        cut(x1, Y4 + 1, x2, y2);
        y2 = Y4;
    }
}
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        cin >> X1 >> Y1 >> X2 >> Y2;
        cin >> X3 >> Y3 >> X4 >> Y4;
        black = n * m / 2;
        white = n * m - black;
        cut(X1,Y1,X2,Y2);
        jishu(X3,Y3,X4,Y4,0);
        printf("%lld %lld\n",white,black);
    }
}

D - Olya and magical square

CodeForces - 1080D

E - Sonya and Matrix Beauty

CodeForces - 1080E

原文地址:https://www.cnblogs.com/smallhester/p/11178090.html

时间: 2024-11-14 12:51:44

HZNU 2019 Summer training 8的相关文章

HZNU 2019 Summer training 6 -CodeForces - 622

A - Infinite Sequence  CodeForces - 622A 题目大意:给你一个这样的数列1,1,2,1,2,3,1,2,3,4,1,2,3,4,5....就是从1~n排列(n++).最后问你第n个位置是什么数字. 思路:如果你花点时间列数列的话会发现,1~n的最后一位对应的位置是1~n的和,那我们就大胆使用二分进行搜索这位数. #include<iostream> #include<algorithm> #include<cstdio> #incl

HZNU 2019 Summer training 4

A - Little C Loves 3 I CodeForces - 1047A 题意:一个数分成三份,每一个都不是3的倍数 题解:分成 (1, 1, n - 2) 或者分成(1, 2, n - 3 ) #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector> #in

HZNU 2019 Summer training 6

A - Infinite Sequence CodeForces - 622A 题意:第一个数是1,接下来是1和2,接下来是1,2, 3,接下来是1,2,3, 4,问第n个数是什么 题解:找出第几轮在找出第几个 #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector>

HDU校赛 | 2019 Multi-University Training Contest 3

2019 Multi-University Training Contest 3 http://acm.hdu.edu.cn/contests/contest_show.php?cid=850 1004. Distribution of books 考虑二分答案,设当前二分出来的是\(x\). 设\(f_i\)表示前\(i\)个能分成最多的段数,使得每一段和都\(\leqslant x\). 转移显然,枚举一个\(j\),若\(s_i-s_j\leqslant x\)则转移,\(s_i\)表示前

[最短路,最大流最小割定理] 2019 Multi-University Training Contest 1 Path

题目:http://acm.hdu.edu.cn/showproblem.php?pid=6582 Path Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3747    Accepted Submission(s): 1075 Problem Description Years later, Jerry fell in love

HZNU 2019 Summer Selection contest 1

A - Nastya Is Buying Lunch CodeForces - 1136D B - Neko Performs Cat Furrier Transform CodeForces - 1152B C - TV Shows CodeForces - 1061D D - Pairs CodeForces - 1169B E - Increasing by Modulo CodeForces - 1169C F - Good Triple CodeForces - 1169D G - T

2019 Multi-University Training Contest 2

题号 A B C D E F G H I J K L 状态 . . . . Ο . . . . Ο Ο Ο 1005  Everything Is Generated In Equal Probability //#pragma comment(linker, "/STACK:102400000,102400000") #include<iostream> #include<stdio.h> #include<stdlib.h> #include&l

2019 Multi-University Training Contest 1 (补题)

1001.Blank 题意:给一列数组填四种数,使得每个给定第$i$个的区间数的种类刚好有$x_{i}$种 我的思路:dp,状态排完序后是四种数最后的位置,转移时判断合法性即可(卡常有点厉害) 代码: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int N = 1e2 + 5; 5 const int MOD = 998244353; 6 7 int dp[2][N][N][N]; 8 int a[N][10]; 9

2019 Multi-University Training Contest 3

#include<bits/stdc++.h> using namespace std; typedef long long ll; const int S=8; ll mult_mod(ll a,ll b,ll c) { a%=c; b%=c; ll ret=0,tmp=a; while (b) { if (b&1) { ret+=tmp; if (ret>c) { ret-=c; } } tmp<<=1; if (tmp>c) tmp-=c; b>&g