自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 收藏
  • 关注

原创 【CCF】201712-2 游戏

时间限制: 1.0s内存限制: 256.0MB问题描述有n个小朋友围成一圈玩游戏,小朋友从1至n编号,2号小朋友坐在1号小朋友的顺时针方向,3号小朋友坐在2号小朋友的顺时针方向,……,1号小朋友坐在n号小朋友的顺时针方向。  游戏开始,从1号小朋友开始顺时针报数,接下来每个小朋友的报数是上一个小朋友报的数加1。若一个小朋友报的数为k的倍数或其末位数(即数的个位)为k,则该小朋友被淘汰...

2019-07-24 11:38:29 112

原创 【CCF】201803-2 碰撞的小球

时间限制: 1.0s内存限制: 256.0MB问题描述数轴上有一条长度为L(L为偶数)的线段,左端点在原点,右端点在坐标L处。有n个不计体积的小球在线段上,开始时所有的小球都处在偶数坐标上,速度方向向右,速度大小为1单位长度每秒。  当小球到达线段的端点(左端点或右端点)的时候,会立即向相反的方向移动,速度大小仍然为原来大小。  当两个小球撞到一起的时候,两个小球会分别向与自己原来...

2019-07-24 10:40:00 118

原创 【CCF】201809-2 买菜

时间限制: 1.0s内存限制: 256.0MB问题描述小H和小W来到了一条街上,两人分开买菜,他们买菜的过程可以描述为,去店里买一些菜然后去旁边的一个广场把菜装上车,两人都要买n种菜,所以也都要装n次车。具体的,对于小H来说有n个不相交的时间段[a1,b1],[a2,b2]…[an,bn]在装车,对于小W来说有n个不相交的时间段[c1,d1],[c2,d2]…[cn,dn]在装车。其中...

2019-07-24 10:07:51 108

原创 【CCF】201812-2 小明上学

时间限制: 1.0s内存限制: 512.0MB题目背景汉东省政法大学附属中学所在的光明区最近实施了名为“智慧光明”的智慧城市项目。具体到交通领域,通过“智慧光明”终端,可以看到光明区所有红绿灯此时此刻的状态。小明的学校也安装了“智慧光明”终端,小明想利用这个终端给出的信息,估算自己放学回到家的时间。问题描述  一次放学的时候,小明已经规划好了自己回家的路线,并且能够预测经过各个路段...

2019-07-24 09:50:36 112

原创 【CCF】201609-1 最大波动

时间限制: 1.0s内存限制: 256.0MB问题描述小明正在利用股票的波动程度来研究股票。小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少。输入格式输入的第一行包含了一个整数n,表示小明拿到的收盘价格的连续天数。  第二行包含n个正整数,依次表示每天的收盘价格。输出格式  输...

2019-07-22 23:01:25 86

原创 【CCF】201903-2 二十四点

时间限制: 1.0s内存限制: 512.0MB#include<cstdio>#include<stack>#include<ctype.h>using namespace std;char s[10];stack<int> num;stack<char> f;bool greater(char x,char y...

2019-07-22 23:00:28 271

原创 【CCF】201612-1 中间数

时间限制: 1.0s内存限制: 256.0MB问题描述在一个整数序列a1, a2, …, an中,如果存在某个数,大于它的整数数量等于小于它的整数数量,则称其为中间数。在一个序列中,可能存在多个下标不相同的中间数,这些中间数的值是相同的。  给定一个整数序列,请找出这个整数序列的中间数的值。输入格式输入的第一行包含了一个整数n,表示整数序列中数的个数。  第二行包含n个正整...

2019-07-22 21:22:55 82

原创 【CCF】201703-1 分蛋糕

时间限制: 1.0s内存限制: 256.0MB问题描述小明今天生日,他有n块蛋糕要分给朋友们吃,这n块蛋糕(编号为1到n)的重量分别为a1, a2, …, an。小明想分给每个朋友至少重量为k的蛋糕。小明的朋友们已经排好队准备领蛋糕,对于每个朋友,小明总是先将自己手中编号最小的蛋糕分给他,当这个朋友所分得蛋糕的重量不到k时,再继续将剩下的蛋糕中编号最小的给他,直到小明的蛋糕分完或者这个...

2019-07-22 21:07:54 76

原创 【CCF】201709-1 打酱油

时间限制: 1.0s内存限制: 256.0MB问题描述小明带着N元钱去买酱油。酱油10块钱一瓶,商家进行促销,每买3瓶送1瓶,或者每买5瓶送2瓶。请问小明最多可以得到多少瓶酱油。输入格式输入的第一行包含一个整数N,表示小明可用于买酱油的钱数。N是10的整数倍,N不超过300。输出格式输出一个整数,表示小明最多可以得到多少瓶酱油。样例输入40样例输出5...

2019-07-22 19:08:37 72

原创 【CCF】201712-1 最小差值

时间限制: 1.0s内存限制: 256.0MB问题描述给定n个数,请找出其中相差(差的绝对值)最小的两个数,输出它们的差值的绝对值。输入格式输入第一行包含一个整数n。  第二行包含n个正整数,相邻整数之间使用一个空格分隔。输出格式  输出一个整数,表示答案。样例输入51 5 4 8 20样例输出1样例说明相差最小的两个数是5和4,它们之间的差值是...

2019-07-22 18:48:24 92

原创 【CCF】201803-1 跳一跳

时间限制: 1.0s内存限制: 256.0MB问题描述近来,跳一跳这款小游戏风靡全国,受到不少玩家的喜爱。  简化后的跳一跳规则如下:玩家每次从当前方块跳到下一个方块,如果没有跳到下一个方块上则游戏结束。  如果跳到了方块上,但没有跳到方块的中心则获得1分;跳到方块中心时,若上一次的得分为1分或这是本局游戏的第一次跳跃则此次得分为2分,否则此次得分比上一次得分多两分(即连续跳到方块...

2019-07-22 18:38:13 88

原创 【CCF】201809-1 卖菜

时间限制: 1.0s内存限制: 256.0MB问题描述在一条街上有n个卖菜的商店,按1至n的顺序排成一排,这些商店都卖一种蔬菜。  第一天,每个商店都自己定了一个价格。店主们希望自己的菜价和其他商店的一致,第二天,每一家商店都会根据他自己和相邻商店的价格调整自己的价格。具体的,每家商店都会将第二天的菜价设置为自己和相邻商店第一天菜价的平均值(用去尾法取整)。  注意,编号为1的商店...

2019-07-22 18:14:17 63

原创 【CCF】201812-1 小明上学

时间限制: 1.0s内存限制: 512.0MB#include<cstdio>int main(){ int r,y,g,n,sum=0; int k,t; scanf("%d%d%d",&r,&y,&g); scanf("%d",&n); for(int i=0;i<n;i++){ ...

2019-07-22 18:00:27 103

原创 【CCF】201903-1 小中大

时间限制: 1.0s内存限制: 512.0MB#include<stdio.h>#include<string.h>int s[100005];int main(){ int n,a,b,c; double d; scanf("%d",&n); for(int i=0;i<n;i++){ sc...

2019-07-22 11:46:05 62

原创 【算法竞赛入门经典】习题3-10 盒子(Box,ACM/ICPC NEERC 2004,UVa 1587)

QIvan works at a factory that produces heavy machinery. He has a simple job — he knocks up wooden boxes of different sizes to pack machinery for delivery to the customers. Each box is a rectangular...

2019-07-22 11:09:31 299

原创 【算法竞赛入门经典】习题3-9 子序列(All in All,UVa 10340)

QYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not disc...

2019-07-22 10:31:39 287

原创 【算法竞赛入门经典】习题3-8 循环小数(Repeating Decimals,ACM/ICPC World Finals 1990,UVa 202)

QThe decimal expansion of the fraction 1/33 is 0.03, where the 03 is used to indicate that the cycle 03 repeats indefinitely with no intervening digits. In fact, the decimal expansion of every ratio...

2019-07-20 17:00:06 477 1

原创 【算法竞赛入门经典】习题3-7 DNA序列(DNA Consensus String,ACM/ICPC Seoul 2006,UVa 1368)

InputYour program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case starts with a line containing...

2019-07-20 15:50:57 237

原创 【算法竞赛入门经典】习题3-6 谜题(Crossword Answers,ACM/ICPC World Finals 1994,UVa 232)

Q:A crossword puzzle consists of a rectangular grid of black andwhite squares and two lists of definitions (or descriptions).One list of definitions is for “words” to be written left toright acro...

2019-07-20 15:06:55 398

原创 【算法竞赛入门经典】习题3-5 谜题(Puzzle,ACM/ICPC World Finals 1993,UVa 227)

此程序仅实现题目的功能,并非严格按照竞赛具体题目而写,仅供参考#include<stdio.h>#include<string.h>char a[6][6];char b[1000];char m[]="ABLR";int c[]={-1,1,0,0};int d[]={0,0,-1,1};int x,y;bool change(char t){ ...

2019-07-20 09:39:36 289

原创 【算法竞赛入门经典】习题3-4 周期串(Periodic Strings,UVa 455)

#include<stdio.h>#include<string.h>char a[100];int main(){ scanf("%s",a); int n=strlen(a); int k=1; int i; bool flag=true; while(k<n){ if(n%k==0){ ...

2019-07-20 08:34:06 185

原创 【算法竞赛入门经典】习题3-3 数数字(Digit Counting,ACM/ICPC Danang 2007,UVa 1225)

#include<stdio.h>#include<string.h>int a[15]={0};int main(){ int n; scanf("%d\n",&n); while(n--){ char c; scanf("%c",&c); a[c-'0']++; ...

2019-07-18 14:45:02 244 1

原创 【算法竞赛入门经典】习题3-2 分子量(Molar Mass,ACM/ICPC Seoul 2007,UVa 1586)

#include<stdio.h>#include<string.h>#include<ctype.h>char s[10000];float value(char x){ if(x=='C') return 12.01; else if(x=='H') return 1.008; else if...

2019-07-18 14:00:34 185

原创 【算法竞赛入门经典】习题3-1 得分(Score,ACM/ICPC Seoul 2005,UVa 1585)

#include<stdio.h>int main(){ int sum=0; //计算得分 int f=0; //用来标记连续O的个数 char x; while(scanf("%c",&x)!=EOF){ if(x=='O'){ f++; sum+=f; ...

2019-07-18 10:54:15 226

原创 【算法竞赛入门经典】思考题 3-2 (统计字符1的个数)

找出程序中的问题#include<stdio.h>#define maxn 10000000+ 10int main(){ char s[maxn]; scanf("%s",s); int tot=0; for(int i=0;i<strlen(s);i++) if(s[i]==1) tot++; printf("%d...

2019-07-18 09:15:35 406

原创 【算法竞赛入门经典】思考题 3-1

?下面哪些需要数组来保存数据 输入一些数,统计个数 输入一些数,求最大值、最小值和平均数 输入一些数,哪两个数最接近 输入一些数,求第二大的值 输入一些数,求它们的方差 输入一些数,统计不超过平均数的个数...

2019-07-18 09:00:33 192

原创 【算法竞赛入门经典】例题3-6 环状序列(Circular Sequence,ACM/ICPC Seoul 2004,UVa 1584)

#include<stdio.h>#include<string.h>const int maxn=105;int n;char s[maxn];bool Less(int i,int j){ for(int k=0;k<n;k++){ if(s[(i+k)%n]!=s[(j+k)%n]) return s[...

2019-07-17 14:45:16 248

原创 【算法竞赛入门经典】例题3-5 生成元(Digit Generator,ACM/ICPC Seoul 2005,UVa 1583)

第一行给出需检查的数的个数m,接着m行每行输入一个数,要求输出该数的生成元。#include<stdio.h>#include<string.h>const int maxn=100005;int s[maxn]={0};int main(){ for(int i=1;i<maxn;i++){ int x=i; i...

2019-07-17 14:35:07 188

原创 【算法竞赛入门经典】 程序3-4 猜数字游戏的提示(Master-Mind Hints,UVa 340)

#include<stdio.h>#include<string.h>int a[1010],b[1010];int main(){ int n; int k=1; while(scanf("%d",&n) && n){ printf("Game %d:\n",k++); for(in...

2019-07-17 14:15:06 212

原创 【算法竞赛入门经典】 程序3-7 回文词

#include<stdio.h>#include<string.h>using namespace std;const char s[]="A 3 HIL JM O 2TUVWXY51SE Z 8 ";char a[30];char Mirror(char x){ if(x>='A'&&x<='Z') ...

2019-07-17 13:32:28 166

原创 【算法竞赛入门经典】 程序 3-6 WERTYU

#include<stdio.h>const char a[]="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";int main(){ char c; int i; while((c=getchar())!=EOF){ for(i=1;a[i]&&a[i]!=c;i++...

2019-07-17 09:48:42 159

原创 【算法竞赛入门经典】 程序 3-5 TeX中的引号

#include<stdio.h>int main(){ char c; int q=1; while((c=getchar())!=EOF){ if(c=='"') { if(q){ printf("``"); } els...

2019-07-17 09:36:55 173

原创 【算法竞赛入门经典】 程序 3-4 竖式问题

#include<stdio.h>#include<string.h>#include<string>#include<iostream>using namespace std;string s;int a[15]={0};bool check(int i){ while(i){ if(!a[i%10])...

2019-07-16 10:41:08 549

原创 【算法竞赛入门经典】 程序 3-3 蛇形填数

#include<stdio.h>#include<string.h>int a[10][10];int main(){ int n,m=1; memset(a,0,sizeof(a)); scanf("%d",&n); int x=0,y=n-1; //起点 a[x][y]=1; while(m<n...

2019-07-16 09:44:52 135

原创 【算法竞赛入门经典】 思考题2-1

原程序2-1#include<stdio.h>int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) printf("%d\n",i); return 0;}输出 2,4,6,8,···,2n 任务1:仅修改第7行#include<stdi...

2019-07-15 15:22:24 149

原创 【算法竞赛入门经典】 习题2-6 排列(permutation)

#include<stdio.h>bool flag[12];int main(){ for(int a=123;a<330;a++){ for(int i=1;i<=9;i++){ flag[i]=false; } int b=2*a; int c=3*a; ...

2019-07-15 15:11:58 210

原创 【算法竞赛入门经典】 习题2-5 分数化小数(decimal)

注意:1.小数的位数是不确定的,所以只能按模拟实际计算过程来输出2.最后一位小数要按其后一位的四舍五入算,不能单纯舍掉其后的小数数字3.即使不到c位小数除法已结束,仍需补齐0#include<stdio.h>int main(){ int a,b,c,k=1; while(scanf("%d%d%d",&a,&b,&c) &&...

2019-07-15 10:46:19 165

原创 【算法竞赛入门经典】 习题2-4 子序列的和(subssequence)

#include<stdio.h>int main(){ long long n,m; int i=1; while(scanf("%lld%lld",&n,&m) && n && m){ double sum=0.0; for(;n<=m;n++){ ...

2019-07-15 10:29:10 188

原创 【算法竞赛入门经典】 习题2-3 倒三角形(triangle)

#include<stdio.h>int main(){ int n; scanf("%d",&n); int i=0; while(n>0){ for(int j=0;j<i;j++) printf(" "); i++; for(int j=0;j<(...

2019-07-15 10:21:00 191

原创 【算法竞赛入门经典】 习题2-1 水仙花数(daffodil)

#include<stdio.h>int main(){ int n,a,b,c,i=1; for(n=100;n<1000;n++){ a=n/100; b=(n%100)/10; c=n%10; int m=a*a*a+b*b*b+c*c*c; if(n==m){ ...

2019-07-15 10:03:14 200

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除