GVKun编程网logo

cmd脚本写一个小学生计算习题

11

对于cmd脚本写一个小学生计算习题感兴趣的读者,本文将会是一篇不错的选择,并为您提供关于2018湖南省第14届大学生计算机程序设计竞赛D:卖萌表情、2018年湖南省第十四届大学生计算机程序设计竞赛、2

对于cmd脚本写一个小学生计算习题感兴趣的读者,本文将会是一篇不错的选择,并为您提供关于2018 湖南省第 14 届大学生计算机程序设计竞赛 D: 卖萌表情、2018年湖南省第十四届大学生计算机程序设计竞赛、2018湖南省第14届大学生计算机程序设计竞赛 A字符画、2018湖南省第14届大学生计算机程序设计竞赛 C: 时间旅行的有用信息。

本文目录一览:

cmd脚本写一个小学生计算习题

cmd脚本写一个小学生计算习题

@echo off
echo 输入你的名字回车(Enter键)一次
Set/p "name=你的名字:"
echo 你好 %name%!

echo 下面是四则运算
echo --------------------------------

echo a=2×3+7
echo a=2×3+7 >>result.txt
echo --------------------------------
echo  %name%输入你的答案回车(Enter键)一次
echo a=
Set/p "a="
echo a=%a% >>result.txt
echo 按任意键查看你答案是否正确...
pause>nul
echo --------------------------------
if "%a%"=="13" (echo 你的a答案对 
Set k1=1) else (echo 你的a答案错,是13
Set k1=0)
if "%a%"=="13" (echo 你的a答案对 >>result.txt
) else (echo 你的a答案错,是13
) >>result.txt
Set/a to=k1
echo --------------------------------
echo %name%你答对了%to%题 
echo %name%你答对了%to%题  >>result.txt
echo --------------------------------
echo 你的回答已保存在result.txt
echo 按任意键关闭...
pause>nul

存成后缀为bat的文件.

运行如图

生成一个result.txt文件显示答题内容

2018 湖南省第 14 届大学生计算机程序设计竞赛 D: 卖萌表情

2018 湖南省第 14 届大学生计算机程序设计竞赛 D: 卖萌表情

Description

已知以下 4 种都是卖萌表情(空白的部分可以是任意字符。竖线是便于展示的分隔符,没有实际意义):

^ ^ |  ^  | <  |  >
 v  | v v |  > | <
    | | < | >

给出 n 行 m 列的字符矩阵,Bobo 希望找出互不重叠的卖萌表情数量的最大值。互不重叠的意思是每个字符只属于至多一个卖萌表情。

  • 1 ≤ n, m ≤ 1000
  • 矩阵只包含 ^v<> 4 种字符。
  • n × m 的和不超过 2 × 106.

Input

输入文件包含多组数据,请处理到文件结束。

每组数据的第一行包含 2 个整数 n 和 m.

接下来 n 行的第 i 行包含长度为 m 的字符串,表示字符矩阵的第 i 行。

Output

对于每组数据输出 1 个整数表示互不重叠的卖萌表情数量的最大值。

Sample Input

2 4
^^^^
>vv<
2 4
vvvv
>^^<
4 2
v>
<>
<>
^>
3 4
^>^>
<v>v
>>>>

Sample Output

2
0
2
2

思路:贪心,由图我们可以看出这个表情分为两种类型,那么对于前两种哪个表情优先级更高一些呢,你可以看图,虽然这个图有点迷,但是仔细看一下应该还是能懂的(尴尬脸),

对于第二类的表情其实没啥区别,优先级一样。那么知道这些就很简单了。直接看代码吧。
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <list>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
const int MOD=1e9+7;
const int maxn=1005;
int n,m,cnt;
char s[maxn][maxn];
bool vis[maxn][maxn];
int main()
{
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        memset(vis,false,sizeof(vis));
        for(int i=1;i<=n;i++)
            scanf("%s",s[i]+1);
//        for(int i=1;i<=n;i++)
//            printf("%s\n",s[i]+1);
        cnt=0;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(s[i][j]==''v'')
                {
                    if(j-2>0)
                    {
                        if((s[i][j-2]==''v''&&vis[i][j-2]==false&&s[i-1][j-1]==''^''&&vis[i-1][j-1]==false))
                        {
                            cnt++;
                            vis[i][j]=true;vis[i][j-2]=true;vis[i-1][j-1]=true;
                        }
                    }
                    if(s[i-1][j-1]==''^''&&s[i-1][j+1]==''^''&&vis[i-1][j-1]==false&&vis[i-1][j+1]==false)
                    {
                        cnt++;
                        vis[i][j]=true;vis[i-1][j-1]=true;vis[i-1][j+1]=true;
                    }
                }
            }
        }
//        printf("%d\n",cnt);
        if(n<3)
            printf("%d\n",cnt);
        else
        {
            for(int i=3;i<=n;i++)
            {
                for(int j=1;j<=m;j++)
                {
                    if(s[i][j]==''<'')
                    {
                        if(s[i-1][j+1]==''>''&&vis[i-1][j+1]==false&&s[i-2][j]==''<''&&vis[i-2][j]==false)
                        {
                            cnt++;
                            vis[i][j]=true;vis[i-1][j+1]=true;vis[i-2][j]=true;
                        }
                    }
                    if(s[i][j]==''>'')
                    {
                        if(s[i-1][j-1]==''<''&&vis[i-1][j-1]==false&&s[i-2][j]==''>''&&vis[i-2][j]==false)
                        {
                            cnt++;
                            vis[i][j]=true;vis[i-1][j-1]=true;vis[i-2][j]=true;
                        }
                    }
                }
            }
            printf("%d\n",cnt);
        }
    }
    return 0;
}
/**********************************************************************
    Problem: 1361
    User: HNCPCteam001
    Language: C++
    Result: AC
    Time:528 ms
    Memory:3996 kb
**********************************************************************/

 

2018年湖南省第十四届大学生计算机程序设计竞赛

2018年湖南省第十四届大学生计算机程序设计竞赛

[TOC]

题目链接

传送门

题目

A题

思路

签到。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
 
typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
 
#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://Code//in.txt","r",stdin)
 
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 200000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
 
int n;
 
int main() {
    scanf("%d", &n);
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo\n");
    printf("..o");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("o.o");
    for(int i = 1; i <= n; ++i) printf(".");
    printf(".o.");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("o.o\n");
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("o.o");
    for(int i = 1; i <= n; ++i) printf(".");
    printf(".o.");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo\n");
    printf("o..");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("o.o");
    for(int i = 1; i <= n; ++i) printf(".");
    printf(".o.");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("o.o\n");
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo");
    for(int i = 1; i <= n; ++i) printf(".");
    printf("ooo\n");
    return 0;
}

B题

思路

打表找规律。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
 
#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("/home/dillonh/CLionProjects/Dillonh/in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)
 
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 200000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
 
int n, m;
int C[4007][2007];
 
int main() {
#ifndef ONLINE_JUDGE
    FIN;
#endif
    for(int i = 0; i <= 4000; ++i) {
        C[i][0] = 1;
        for(int j = 1; j <= min(i, 2000); ++j) {
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
        }
    }
    while(~scanf("%d%d", &n, &m)) {
        printf("%lld\n", 1LL * (C[n+m][m] - 1) * (C[n+m][m] - 1) % mod);
    }
    return 0;
}

C题

思路

看样例猜。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
 
#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("/home/dillonh/CLionProjects/Dillonh/in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)
 
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 200000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
 
int h, c;
 
int main() {
    while(~scanf("%d%d", &h, &c)) {
        printf("%d\n", h > c ? h : c + 1);
    }
    return 0;
}

E题

思路

初始时联通快有$n\times m$个,由于在每次进行操作之后重新数联通块比较复杂,因此我们可以将思路转换一下,变成每次操作后联通块减少了$x$,那么答案就是$n\times m-x$。

我们可以发现每次增加一条新的横线(前面没有对这一行进行操作)后联通块减少了$m-1$个,每次增加一条竖线后联通块减少了$n-1$个。

我们假设横线数目为$h$,竖线数目为$w$,那么当只有横线时答案为$n\times m-h\times(m-1)$,当只有竖线时答案为$n\times m-w\times(n-1)$。当既有横线又有竖线时需要稍微容斥一下,因为对于交叉点我们会重复减掉,因此需要加回来,被重复减掉部分为$(h-1)\times(w-1)$,此时答案为$n\times m-h\times(m-1)-w\times(n-1)+(h-1)\times(w-1)$。

注意同一行被操作多次只能被算一次,因此我们可以考虑用左闭右开线段树来维护。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
 
typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
 
#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://Code//in.txt","r",stdin)
 
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 200000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
 
bool lazy[3][maxn<<2];
int n, m, q, cnt;
int op[maxn], l[maxn], r[maxn], sum[3][maxn<<2], num[maxn*2];
 
void push_down(int rt, int l, int r, int id) {
    if(!lazy[id][rt]) return;
    lazy[id][rt] = 0;
    lazy[id][lson] = lazy[id][rson] = 1;
    int mid = (l + r) >> 1;
    sum[id][lson] = num[mid+1] - num[l];
    sum[id][rson] = num[r+1] - num[mid+1];
}
 
void push_up(int rt, int id) {
    sum[id][rt] = sum[id][lson] + sum[id][rson];
}
 
void build(int rt, int l, int r) {
    for(int i = 0; i < 2; ++i) sum[i][rt] = 0, lazy[i][rt] = false;
    if(l == r) return;
    int mid = (l + r) >> 1;
    build(lson, l, mid), build(rson, mid + 1, r);
}
 
void update(int rt, int l, int r, int L, int R, int id) {
    if(l == L && r == R) {
        sum[id][rt] = num[R+1] - num[L];
        lazy[id][rt] = true;
        return;
    }
    push_down(rt, l, r, id);
    int mid = (l + r) >> 1;
    if(R <= mid) update(lson, l, mid, L, R, id);
    else if(L > mid) update(rson, mid + 1, r, L, R, id);
    else {
        update(lson, l, mid, L, mid, id);
        update(rson, mid + 1, r, mid + 1, R, id);
    }
    push_up(rt, id);
}
 
int getnum(int x) {
    return lower_bound(num + 1, num + cnt + 1, x) - num;
}
 
int main() {
#ifndef ONLINE_JUDGE
    FIN;
#endif
    while(~scanf("%d%d%d", &n, &m, &q)) {
        cnt = 0;
        for(int i = 1; i <= q; ++i) {
            scanf("%d%d%d", &op[i], &l[i], &r[i]);
            num[++cnt] = l[i], num[++cnt] = r[i] + 1;
        }
        sort(num + 1, num + cnt + 1);
        cnt = unique(num + 1, num + cnt + 1) - num - 1;
        build(1, 1, cnt);
        for(int i = 1; i <= q; ++i) {
            l[i] = getnum(l[i]), r[i] = getnum(r[i]+1);
            if(op[i] == 1) {
                update(1, 1, cnt, l[i], r[i]-1, 0);
            } else {
                update(1, 1, cnt, l[i], r[i]-1, 1);
            }
            // printf("[%d %d]\n", sum[0][1], sum[1][1]);
            LL ans = 1LL * n * m - 1LL * sum[0][1] * (m - 1) - 1LL * sum[1][1] * (n - 1);
            if(sum[0][1] && sum[1][1]) ans += 1LL * (sum[0][1] - 1) * (sum[1][1] - 1);
            printf("%lld\n", ans);
        }
    }
    return 0;
}

H题

思路

由于查询时保证$r-l\leq 2$,因此我们可以用三个树状数组分别存下以$i$为左端点,区间长度为$0,1,2$的区间被哪些区间覆盖过。

插入时对于$[l,r]$的每个数作为左端点区间长度为$0$的均有被覆盖,$[l,r-1]$为左端点区间长度为$1$的均有被覆盖,$[l,r-2]$为左端点区间长度为$2$的均有被覆盖,分别进行$update$即可。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
 
#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("/home/dillonh/CLionProjects/Dillonh/in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)
 
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 100000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
 
inline int read() {
    int f = 0, x = 0;
    char ch = getchar();
    while (ch < ''0'' || ch > ''9'') f |= (ch == ''-''), ch = getchar();
    while (ch >= ''0'' && ch <= ''9'') x = (x << 3) + (x << 1) + ch - ''0'', ch = getchar();
    return x = f ? -x : x;
}
 
int n, q, op, l, r;
int tree[5][maxn];
 
void bit_add(int x, int id, int val) {
    while(x <= n) {
        tree[id][x] += val;
        x += lowbit(x);
    }
}
 
int bit_query(int x, int id) {
    int ans = 0;
    while(x) {
        ans += tree[id][x];
        x -= lowbit(x);
    }
    return ans;
}
 
int main() {
#ifndef ONLINE_JUDGE
    FIN;
#endif
    while(~scanf("%d%d", &n, &q)) {
        for(int i = 0; i <= 2; ++i) {
            for(int j = 0; j <= n; ++j) tree[i][j] = 0;
        }
        while(q--) {
            op = read(), l = read(), r = read();
            if(op == 1) {
                bit_add(l, 0, 1);
                bit_add(r + 1, 0, -1);
                if(l <= r - 1) {
                    bit_add(l, 1, 1);
                    bit_add(r, 1, -1);
                }
                if(l <= r - 2) {
                    bit_add(l, 2, 1);
                    bit_add(r - 1, 2, -1);
                }
            } else {
                printf("%d\n", bit_query(l, r-l));
            }
        }
    }
    return 0;
}

J题

思路

我们考虑当前$dfs$到结点$u$,从$1$到$u$的父亲结点得到的答案为$sum$,那么$f_u=sum+u$的贡献。

当$a[u]$在$1$到$u$这条链上是第一次出现时,此时$u$的贡献为这条链上不同数的个数;

当$a[u]$是第二次出现时,此时$u$的贡献为上一次$a[u]$出现位置到$u$的路径上不同数的个数$+1$,这个$1$表示的有序对是$(a[u],a[u])$。

当$a[u]$出现次数大于$2$时,此时$u$的贡献为上一次$a[u]$出现位置到$u$的路径上不同数的个数。

在回溯的时候记得清除$u$造成的影响。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
 
#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("/home/dillonh/CLionProjects/Dillonh/in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)
 
const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 200000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
 
int ans[maxn], sum;
int n, u, tot, cnt;
int head[maxn], a[maxn], vis[maxn], lst[maxn];
 
struct edge {
    int v, next;
}ed[maxn*2];
 
void add(int u, int v) {
    ed[tot].v = v;
    ed[tot].next = head[u];
    head[u] = tot++;
}
 
void dfs(int u) {
    int tmp = 0;
    if(!vis[a[u]]) tmp = cnt, ++cnt;
    else if(vis[a[u]] == 1) tmp = cnt - lst[a[u]] + 1;
    else tmp = cnt - lst[a[u]];
    ans[u] = sum + tmp;
    int pp = lst[a[u]];
    lst[a[u]] = cnt;
    sum += tmp;
    ++vis[a[u]];
    for(int i = head[u]; ~i; i = ed[i].next) {
        int v = ed[i].v;
        dfs(v);
    }
    sum -= tmp;
    --vis[a[u]];
    if(vis[a[u]] == 0) --cnt;
    lst[a[u]] = pp;
}
 
int main() {
    while(~scanf("%d", &n)) {
        tot = cnt = sum = 0;
        assert(n >= 1 && n <= 100000);
        for(int i = 1; i <= n; ++i) vis[i] = ans[i] = lst[i] = 0, head[i] = -1;
        for(int i = 2; i <= n; ++i) {
            scanf("%d", &u);
            assert(u >= 1 && u <= n && u != i);
            add(u, i);
        }
        for(int i = 1; i <= n; ++i) {
            scanf("%d", &a[i]);
            assert(a[i] >= 1 && a[i] <= n);
        }
        dfs(1);
        for(int i = 2; i <= n; ++i) printf("%d\n", ans[i]);
    }
    return 0;
}

K题

思路

我们将$a$做个前缀和,然后考虑每个$b$的贡献即可。

代码

#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

#define fi first
#define se second
#define lson (rt<<1)
#define rson (rt<<1|1)
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://Code//in.txt","r",stdin)

const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 500000 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;

int n, m, L, R;
LL sum[maxn], a[maxn], b[maxn];
 
int main() {
    while (~scanf("%d%d%d%d", &n, &m, &L, &R)) {
        L += 2, R += 2;
        sum[0] = 0;
        for (int i = 1; i <= n + 1; i++) scanf("%lld", &a[i]), sum[i] = sum[i - 1] + a[i];
        for (int i = 1; i <= m + 1; i++) scanf("%lld", &b[i]);
        LL ans = 0;
        for (int i = 1; i <= m + 1; i++) {
            int l = max(1, L - i), r = min(n + 1, R - i);
            if (l > n + 1 || r < 1) continue;
            ans = (ans + 1LL * b[i] * ((sum[r] - sum[l - 1] + mod) % mod) % mod) % mod;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

2018湖南省第14届大学生计算机程序设计竞赛 A字符画

2018湖南省第14届大学生计算机程序设计竞赛 A字符画

Description

读入 w,请输出 2018 的字符画,两个数字之间有 w 个空格。具体格式请参考样例输出。

  • 1 ≤ w ≤ 2018

Input

输入文件只包含 1 个整数 w.

Output

输出 5 行,每行 12 + 3w 个字符(只包含 o 和 . 两种,字符画的部分用 o,空格的部分用 .),以换行符结尾。

Sample Input

2

Sample Output

ooo..ooo..ooo..ooo
..o..o.o...o...o.o
ooo..o.o...o...ooo
o....o.o...o...o.o
ooo..ooo..ooo..ooo

解释:这是一道水题,就是模拟,2018这个字符不变变化的只有中间的那个.的个数,所以直接写就行
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <list>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
const int MOD=10056;
const int maxn=2016;
int w;

int main()
{
    scanf("%d",&w);
    for(int i=1;i<=5;i++)
    {
        if(i==1)
        {
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
        }
        else if(i==2)
        {
            printf("..o");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("o.o");
            for(int j=1;j<=w;j++)
                printf(".");
            printf(".o.");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("o.o");
        }
        else if(i==3)
        {
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("o.o");
            for(int j=1;j<=w;j++)
                printf(".");
            printf(".o.");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
        }
        else if(i==4)
        {
            printf("o..");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("o.o");
            for(int j=1;j<=w;j++)
                printf(".");
            printf(".o.");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("o.o");
        }
        else
        {
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
            for(int j=1;j<=w;j++)
                printf(".");
            printf("ooo");
        }
        printf("\n");
    }
    return 0;
}

/**********************************************************************
    Problem: 1358
    User: HNCPCteam001
    Language: C++
    Result: AC
    Time:0 ms
    Memory:2024 kb
**********************************************************************/

 

2018湖南省第14届大学生计算机程序设计竞赛 C: 时间旅行

2018湖南省第14届大学生计算机程序设计竞赛 C: 时间旅行

Description

假设 Bobo 位于时间轴(数轴)上 t0 点,他要使用时间机器回到区间 (0, h] 中。

当 Bobo 位于时间轴上 t 点,同时时间机器有 c 单位燃料时,他可以选择一个满足 xhhc⌈xh⌉⋅h≤c 的非负整数 x, 那么时间机器会在 [0, x]中随机整数 y,使 Bobo 回到 (t − y) 点,同时消耗 y 单位燃料。 (其中 ⌈ ⋅ ⌉ 表示上取整)

因为时间机器的随机性,对于给出的参数 h 和时间机器剩余燃料 c,Bobo 想知道能够保证回到区间 (0, h] 中的 t0 的最大值。

  • 1 ≤ h ≤ 109
  • 0 ≤ c ≤ 109
  • 数据组数不超过 105.

Input

输入文件包含多组数据,请处理到文件结束。

每组数据包含 2 个整数 h 和 c.

Output

对于每组数据输出 1 个整数表示 t0 的最大值。

Sample Input

100 99
100 100
100 149

Sample Output

100
101
150

解题:这题莽一发就过了,你推一下会发现x的最大值是c/h的向下取整乘以h,然后依照题意就选择这个值运算,到最后小于h的时候就是比h小的值+1。最后结果还是c+1。
当然你要考虑一开始h和c的大小,如果c比较小的时候,就是答案就是h的值。
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <list>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
const int MOD=10056;
const int maxn=2016;
int h,c;

int main()
{
    while(scanf("%d %d",&h,&c)!=EOF)
    {
        if(h>c)
            printf("%d\n",h);
        else
            printf("%d\n",c+1);
    }
    return 0;
}

/**********************************************************************
    Problem: 1360
    User: HNCPCteam001
    Language: C++
    Result: AC
    Time:108 ms
    Memory:2024 kb
**********************************************************************/

 

今天关于cmd脚本写一个小学生计算习题的介绍到此结束,谢谢您的阅读,有关2018 湖南省第 14 届大学生计算机程序设计竞赛 D: 卖萌表情、2018年湖南省第十四届大学生计算机程序设计竞赛、2018湖南省第14届大学生计算机程序设计竞赛 A字符画、2018湖南省第14届大学生计算机程序设计竞赛 C: 时间旅行等更多相关知识的信息可以在本站进行查询。

本文标签: