• 1036: Shepherd
  • 1112: 对于数字的强迫症
  • 1137: 最后一次队内赛的a+b
  • 1278: Sequence(哈希)
  • 1279: Sort photos(读题)
  • 1653: 这样真的好么(*^*)
  • 1654: 据说题目里藏着某人的QQ号\(^o^)/~
  • 1655: 某人好想AC哦~
  • 1657: O(∩_∩)O哈!
  • 1658: O__O "… 就是那道中文题
  • 1663: 字符识别?
  • 1672: 憋说话,好好算
  • 1674: 买买买
  • 1109: 胥哥的DOTA


1036: Shepherd

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 296  Solved: 76
[Submit][Status][Web Board]

Description

Hehe keeps a flock of sheep, numbered from 1 to n and each with a weight wi. To keep the sheep healthy, he prepared some training for his sheep. Everytime he selects a pair of numbers (a,b), and chooses the sheep with number a, a+b, a+2b, … to get trained. For the distance between the sheepfold and the training site is too far, he needs to arrange a truck with appropriate loading capability to transport those sheep. So he wants to know the total weight of the sheep he selected each time, and he finds you to help him.

Input

There’re several test cases. For each case:
The first line contains a positive integer n (1≤n≤10^5)---the number of sheep Hehe keeps.
The second line contains n positive integer wi(1≤n≤10^9), separated by spaces, where the i-th number describes the weight of the i-th sheep.
The third line contains a positive integer q (1≤q≤10^5)---the number of training plans Hehe prepared.
Each following line contains integer parameters a and b (1≤a,b≤n)of the corresponding plan.

Output

For each plan (the same order in the input), print the total weight of sheep selected.

Sample Input

5 1 2 3 4 5 3 1 1 2 2 3 3

Sample Output

15 6 3

【分析】注意特判一下b==0的情况(虽然题上说了b>=1了)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=1e5+5;
int w[maxn];
int main()
{int n;while(~scanf("%d",&n)){long long sum=0;memset(w,0,sizeof(w));for(int i=0;i<n;i++){scanf("%d",&w[i]);sum+=w[i];} int q;scanf("%d",&q);while(q--){int a,b;long long ans=0;scanf("%d%d",&a,&b);if(b==0)ans=w[a-1];else if(b==1&&a==1)ans=sum;elsefor(int i=a-1;i<n;i+=b)ans+=w[i];printf("%lld\n",ans);}}return 0;} 

1112: 对于数字的强迫症

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 473  Solved: 293
[Submit][Status][Web Board]

Description

有一串数字,它虽然长,但他还是一串数字。我有强迫症,我讨厌看到有同样的数字在一起,我想在中间加一个比它们大一点的数。比如123411,我希望它变成1234121。比如333,我希望它变成34343。你能帮我处理一下这些数字吗。

Input

每行输入一串数,对于这些数进行处理,这串数,最多有1000位。

Output

输出你处理后的数,当输入的数为0时结束。

Sample Input

111 991 10001 0

Sample Output

12121 91091 1010101

#include<bits/stdc++.h>
using namespace std;
char s1[1005];
int main()
{while(cin>>s1&&s1[0]!='0'){int l=strlen(s1);for(int i=0;i<l-1;i++){cout<<s1[i];if(s1[i]==s1[i+1]){if(s1[i]=='9')cout<<"10"; /注意对9的讨论else printf("%c",s1[i]+1);}}cout<<s1[l-1]<<endl;}return 0;
}

1137: 最后一次队内赛的a+b

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1204  Solved: 410
[Submit][Status][Web Board]

Description

最后一次队内赛了,一年又快过去了,时间过的好快,我们又老了一年。在此同时,我送给大家一道超简单题

Input

输入两个数,a,b(a,b 均为20位以内的正整数)

Output

输出,a+b的另类输出

Sample Input

1 1 2 3

Sample Output

11 23

【分析】emmm很烦,用了strcat()函数,但是没有考虑连接后会溢出的问题o(╥﹏╥)o

 strcat函数常见的错误就是数组越界,即两个字符串连接后,长度超过第一个字符串数组定义的长度,导致越界

所以,,,只能将第一个参数定义长点。

或者,不用函数,直接cout<<s1<<s2,反正怎么做都很水啦


1278: Sequence(哈希)

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 675  Solved: 202
[Submit][Status][Web Board]

Description

There is a sequence of n numbers. And in this sequence, there is only one number appears twice.
Can you tell me which number appears twice.

Input

There are multiple test cases in the input file.
In each case the first line contains an integer n (2<=n<=1000) — the size of the sequence.
The second line contains n integers a1, a2, ..., an (1<=ai<=1000) — the elements of the sequence.

Output

For each case print a single line with the number.

Sample Input

2

1 1

4

1 2 2 3

Sample Output

1

2

HINT

Source

xzy

【分析】哈希数组,统计每个数字出现的次数即可。


1279: Sort photos(读题)

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 537  Solved: 141
[Submit][Status][Web Board]

Description

Imagine you have a pile of n photos. Some of them are faced upwards and the others faced downwards. Your goal is to sort them so that all the photos are faced the same direction. The only operation you are allowed to do is to take any amount of the photos if their direction is same to the other direction. Write the program that calculates the minimum number of such operations needed to complete the sorting goal.

Input

There are multiple test cases in the input file.
For each test case, the first line is n (0<n<10^5) - the number of photos.
The second line is n characters "D" - faced down or "U" - faced up.

Output

For each test case there is a single integer number - minimal number of flip operations required to sort the photos pile.

Sample Input

5

UUDUU

4

UDUD

Sample Output

1

2

HINT

Source

xzy

【分析】注意读题,题目要求的是最小翻转次数的前提是相邻的两个字符是不一样的时候进行翻转,而不是任意翻转,不能不管相邻的两个字符的情况就直接计算两个字符出现的次数然后求最小。


1653: 这样真的好么(*^*)

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 255  Solved: 129
[Submit][Status][Web Board]

Description

在某人参加的某一场比赛中,一共有k位选手参赛,他们的编号是1到k。主办方准备了n个气球,主办方同样把这n个气球随机的编号为1到k中的一个数(保证n可以整除k),然后比赛胜利的规则就是,主办方随机的选择一个气球,如果这个气球的编号是X,那么X选手就胜出...,这样真的好么(*^*),主办方为了体现自己的,暗室不欺 不同流俗 不欺暗室 不忘沟壑 赤子之心 德厚流光 高情远致 高山景行 功德无量 厚德载物 怀瑾握瑜 蕙心纨质 见危授命 鞠躬尽瘁,死而后已 精金良玉 敬老慈幼 良金美玉 明德惟馨 年高德劭 前人栽树,后人乘凉 青天白日 山高水长 拾金不昧 玉洁松贞 沅茝沣兰 云中白鹤 志士仁人等高尚的品德.决定重新编号,使得每个人获胜的概率是一样哒~~,所以这位高尚的主办方想知道最少得修改几次哦!!!

Input

多组测试,请处理到文件末尾,输入的格式是,第一行是n,k(k<n<=100)接下来n个数,表示气球的编号。

Output

一个数,表示需要修改的次数。

Sample Input

4 2

2 1 2 2

6 2

2 2 1 1 1 2

Sample Output

1

0

HINT

样例解释:1 由 2 1 2 2 --->1 1 2 2

【分析】水题。因为编号是1~k,每一个都要有。而k整除n,所以求平均每个数的数量为n/k,所以只要统计比这个数小的与它的差值和就好了。

【代码】

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[105],b[105];
int main()
{int n,k;while(~scanf("%d%d",&n,&k)){memset(b,0,sizeof(b));for(int i=1;i<=n;i++){scanf("%d",&a[i]);b[a[i]]++;} int ans=n/k,cnt=0;for(int i=1;i<=k;i++){if(b[i]<ans)cnt+=ans-b[i];}cout<<cnt<<endl;}
}

1654: 据说题目里藏着某人的QQ号\(^o^)/~

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 333  Solved: 125
[Submit][Status][Web Board]

Description

某人喜欢把自己的字符串加密。加密是这样的,有一个字母与数字的转换表。把字符串的中的每一个字符转换为对应的数字。然后把这些数字相乘,最后再把这个数字对 751492854 取余数

Input

多组数据,处理到文件末尾。一行字符串(只有字母组成,长度小于1000)

Output

输出一个整数表示答案

Sample Input

d

Sample Output

5

HINT

A(a):6

B(b):9

C(c):0

D(d):5

E(e):8

F(f):1

G(g):9

H(h):4

I(i):6

J(j):3

K(k):2

L(l):34

M(m):67

N(n):67

O(o):78967

P(p):345

Q(q):454

R(r):434

S(s):345

T(t):12

U(u):978

V(v):563

W(w):34

X(x):34

Y(y):5885

Z(z):45

【分析】水题

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int str[]={6,9,0,5,8,1,9,4,6,3,2,34,67,67,78967,345,454,434,345,12,978,563,34,34,5885,45};
int main()
{string s;while(cin>>s){long long sum=1;int len=s.length();for(int i=0;i<len;i++){sum*=str[tolower(s[i])-'a'];sum%=751492854;}cout<<sum<<endl;}return 0;
}

1655: 某人好想AC哦~

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 220  Solved: 106
[Submit][Status][Web Board]

Description

给你一个字符串S和一个字符串的P,希望你从s中删除p(注意一点的是,删除p后,可能又会形成一个新的p)

Input

一行2个字符串S,P;(长度小于100)

Output

输出S删除P后的结果

Sample Input

woyaowwwaaaac wa

Sample Output

woyaoac

HINT

解释;

第一步:woyaowwwaaaac--->woyaowwaaac

第二步:woyaowwaaac---->woyaowaac

第三步:woyaowaac--->woyaoac

【分析】水题。string相关函数的使用

【代码】

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{string s;while(cin>>s){string str;cin>>str;int len=str.length();while(s.find(str)!=string::npos){int pos=s.find(str);s.erase(s.begin()+pos,s.begin()+pos+len);}cout<<s<<endl;}return 0;
}

1657: O(∩_∩)O哈!

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 322  Solved: 130
[Submit][Status][Web Board]

Description

现在有个n个同学的姓名和成绩,按照分数从大到小,分数相同的按照名字的字典序从小到大排列。

Input

多组测试,处理到文件末尾。一个数n,接下来是n(n<=100)行,每行一个姓名,成绩

Output

排序的结果

Sample Input

4

zcc 59

ayer 90

huhu 90

zhang 0

Sample Output

ayer 90

huhu 90

zcc 59

zhang 0

【分析】结构体排序,重写cmp函数就好。水题

【代码】

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct node{string name;int score;
}a[105];
bool cmp(node x,node y)
{return x.score!=y.score?x.score>y.score:x.name<y.name;
}
int main()
{int n;while(~scanf("%d",&n)){for(int i=0;i<n;i++)cin>>a[i].name>>a[i].score;sort(a,a+n,cmp);for(int i=0;i<n;i++)cout<<a[i].name<<" "<<a[i].score<<endl;}return 0;
}

1658: O__O "… 就是那道中文题

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 458  Solved: 139
[Submit][Status][Web Board]

Description

有一天某人得到了一组数据,然后烦人的是,有位同学老是询问某一段区间[L,r]范围的平均值(只要整数部分)= =。某人无法解决,向你求救、

Input

多组测试,处理到文件末尾。一行一个n,m(n,m<=100000), 接下来一行n个数字(每个数小于等于200)。

再接下来是m行,每行是两个数L,R;

Output

输出答案。

Sample Input

5 4

1 2 3 4 5

1 1

1 2

1 5

2 4

Sample Output

1

1

3

3

【分析】计算前缀和。注意用scanf和printf,不然会超时

【代码】

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=1e5+5;
int sum[maxn];
int main()
{int n,m;while(~scanf("%d%d",&n,&m)){memset(sum,0,sizeof(sum));for(int i=1;i<=n;i++){int x;scanf("%d",&x);sum[i]=x+sum[i-1];}while(m--){int x,y;scanf("%d%d",&x,&y);int l=y-x+1;printf("%d\n",(sum[y]-sum[x-1])/l);}}return 0;
}

1663: 字符识别?

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 103  Solved: 61
[Submit][Status][Web Board]

Description

你的任务是写一个程序进行字符识别。别担心,你只需要识别1, 2, 3,如下:

.*.  ***  ***
.*.  ..*  ..*
.*.  ***  ***
.*.  *..  ..*
.*.  ***  ***

Input

输入仅包含一组数据,由6行组成。第一行为字符的个数n(1<=n<=10)。以下5行每行包含4n个字符。每个字符恰好占5行3列,然后是一个空列(用"."填充)。

Output

输出应包含一行,即识别出的各个字符。

Sample Input

3
.*..***.***.
.*....*...*.
.*..***.***.
.*..*.....*.
.*..***.***.

Sample Output

123

【分析】找规律。会发现只有第4行3个数字是不同的。通过求余确定位置从而确定数字。

【代码】

#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
int main(){int n,i,j,k;while(~scanf("%d",&n)){getchar();string s1,s2;for(i=0;i<5;i++){if(i==3)cin>>s1;else cin>>s2;}for(j=0;j<n*4;j++){if(s1[j]=='*'){if(j%4==1)printf("1");else if(j%4==0)printf("2");else if(j%4==2)printf("3");}}printf("\n");}return 0;
}

1672: 憋说话,好好算

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 512  Solved: 196
[Submit][Status][Web Board]

Description

今天是热闹的双11节日,注定今天是无眠之日,你心里想着,我要快点刷完这几道题,去看一看我那价值连城的购物车,然而,刷题的时间总是过的飞快。一转眼就是夜晚了,你也刷完了题目, 这个时候,你决定出去呼吸一下新鲜的空气,也许是想去看看月亮,来个“但愿人长久,千里共婵娟”.....,突然,你陷入深思,似乎是你发现了什么,抑或是突然领悟到了什么,从你那炯炯有神,目光冰冷,眼带笑意,星目含威,锐利有神,深邃犀利,眼若饥鹰,双眼如潭,碧眼盈波,眼放光华的眼神中看的出,你正在数着对面的那栋宿舍,有几个人还没睡......,万万想不到的是,你是这样数着的,先从下到上从一开始数,数出了这栋楼是n层,然后每一层有m户人家。细心的你又发现。每户人家都是3个窗户,机智的你就认为如果一户人家没睡,正在狂欢双11,就至少有俩窗子在亮着。看你那扭曲的面部,一定是在算几户人家还么睡。(亮着的窗户用1,表示,灭的是0)

Input

第一行两个数n,m分别表示楼的高度,每层的住户数。接下来n行,每行m*3个数,表示窗户的状态(n,m<=1000)

Output

输出一个数表示几户人家没睡哇

Sample Input

2 2

1 1 0 0 0 0

1 0 1 0 0 1

Sample Output

2

【分析】简单题,模拟就好。注意多组测试数据,不然会wa的

#include<bits/stdc++.h>
using namespace std;
int main()
{int n,m,ans=0;while(~scanf("%d%d",&n,&m)){ans=0;for(int i=0;i<n;i++){for(int j=0;j<m;j++){int x,y,z;scanf("%d%d%d",&x,&y,&z);if(x+y+z>=2)ans++;}}cout<<ans<<endl;}return 0;
}

1674: 买买买

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 648  Solved: 199
[Submit][Status][Web Board]

Description

今天甲乙丙三个人在gaoji,他们在网上买了一堆东西(都为非负整数),已知甲乙丙一共买了x件物品,甲乙买的东西减去丙买的为y,甲买的物品比乙多z件。求甲乙丙各自买了多少。

Input

多组测试数据。

输入x,y,z。(fabs(x),fabs(y),fabs(z)<=1e10)

Output

输出甲乙丙买的件数,如果不可能则输出wangwangwang

Sample Input

1 1 2

4 2 1

Sample Output

wangwangwang

2 1 1

【分析】水题。算算就出来了

【代码】

#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{long long x,y,z;while(~scanf("%lld%lld%lld",&x,&y,&z)){long long a,b,c;a=x+y+2*z;b=x+y-2*z;c=x-y;if(a<0||b<0||c<0||a%4!=0||b%4!=0||c%2!=0)printf("wangwangwang\n");else printf("%lld %lld %lld\n",a/4,b/4,c/2);}return 0;
}

1109: 胥哥的DOTA(水题)

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 371  Solved: 179
[Submit][Status][Web Board]

Description

集训队的孩子们一定听过一个叫XZY的编程大神吧,其实这不仅是编程大神,而且是DOTA大神,曾带这一群DOTA菜鸟虐爆电脑,可是这个DOTA大神最近竟然要说要戒DOTA了,据说还把DOTA给删了(显然是假的。。。。)。经过本人多天的调查原因是这样的:一天胥哥正在中路和别人兴致勃勃的SOLO中,在即将要赢,还未赢的关键时刻,突然天空飞来一只神箭(白虎的箭),将他射中,从杀人到被杀的感觉使他大叫“坑爹!!!剧本不是这样的呀!!”,最后总结得出没有把计算清楚!!所以为了以后能更好的DOTA,他决定先去学ACM,学好算法!!现在正好有道关于这类的题目希望大家能帮他解决!!题目是这样的:

在一条长度为n的直线上有m个点,每个点上有一只白虎,能向直线的任意一个地方射箭,每只白虎的能力为m,能力各不相同,被射中后的伤害为白虎所在的点到箭射到的点的距离L*白虎的能力m,现在希望你找出一个地方使得受到的伤害最小,并输出伤害。

Input

有多组数据,每组数据的第一行有两个数n(0<n<1000),m(1=<m<=100),代表直线的长度和白虎的数量,

然后接下来m行,每行有两个数dis(dis<n),cut(cut<100)代表白虎所在点得位置和白虎的能力。

Output

输出最小的伤害,每个输出占一行

Sample Input

10 2

4 6

6 10

Sample Output

12

【分析】水题,不要想太多,数据不大,循环过去就好了。

【代码】

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=1e3+5;
struct node{int dis;int p;
}a[maxn];
bool cmp(node x,node y)
{return x.p<y.p;
}
int main()
{int n,m;while(~scanf("%d%d",&n,&m)){for(int i=0;i<m;i++)scanf("%d%d",&a[i].dis,&a[i].p);int minn=999999999; for(int i=0;i<=n;i++){int sum=0;for(int j=0;j<m;j++)sum+=fabs(i-a[j].dis)*a[j].p;minn=min(minn,sum);}printf("%d\n",minn);}
}

zcmu之水题来一波~相关推荐

  1. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  2. 蓝桥杯 参考题目 黄金队列(水题)

    黄金分割数0.618与美学有重要的关系.舞台上报幕员所站的位置大约就是舞台宽度的0.618处,墙上的画像一般也挂在房间高度的0.618处,甚至股票的波动据说也能找到0.618的影子.... 黄金分割数 ...

  3. buu 水题记录(一)

    buuctf crypto Before Crypto MD5 Url编码 看我回旋踢 一眼就解密 摩丝 变异凯撒 Quoted-printable Rabbit RSA 篱笆墙的影子 丢失的MD5 ...

  4. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  5. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  6. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  7. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  8. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  9. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

最新文章

  1. python 博弈论 库_SHAP:Python的可解释机器学习库
  2. 从分子层面雕刻肌肉,新数学模型预测锻炼肌肉最优方式
  3. zemax微透镜阵列示例_阵列反向! Ruby中的示例方法
  4. 数据库表名字段名命名规范
  5. c语言 和 运算顺序,二 如何学习C语言的运算符和运算顺序
  6. mysql数据库下载及安装教程
  7. poi-tl——Word模板生成器
  8. 微信小程序css方式animation动画弹幕实现
  9. python怎样下载numpy_python下载numpy的方法是什么
  10. java pos58打印_POS58小票打印机
  11. 【Android音视频开发】【007】SurfaceView实现H264播放器
  12. 第一章 Python pyodbc连接access数据库的使用方法
  13. 深入 Parcel架构与流程
  14. Day16 GUI编程:贪吃蛇
  15. LibreOffice 6.2.2 Office办公套件发布
  16. Chatgpt 指令收集
  17. linux 下的 source,sh,./三者区别
  18. Big Faceless:PDF Viewer for JAVA Crack
  19. 华为2015年实习招聘机试
  20. 数值分析实习作业(各种插值函数与积分公式的python代码实现)

热门文章

  1. python的cfg是什么模块_python操作cfg配置文件方式
  2. python中encoding是什么意思_python中encoding是什么意思
  3. 【腾讯开发者大会】天刀手游开发历程(笔记)
  4. C程序设计语言之第1章 导言
  5. UBUNTU使用RTL8811CU网卡(包含树莓派)
  6. java的博_小博老师解析Java核心技术 ——I/O流
  7. 攻防世界密码学 浅尝
  8. OpenGL画三角形
  9. OMAP3530-mini调试笔记(2)
  10. 谈谈对数据治理的理解