A.题意就是把字符串里面的数字按增序排列,直接上代码。

#include <string.h>
#include <stdio.h>
#include <algorithm> using namespace std; int main()
{
char s[1005];
int num[105];
while (scanf("%s" , s) != EOF)
{
int l = strlen(s);
int t = 0;
int cnt = 0;
for (int i = 0; i <= l; i++)
{
if (s[i] == '+' || !s[i])
{
num[++cnt] = t;
t = 0;
continue;
}
t = t*10 + s[i]-'0';
}
sort(num+1, num+cnt+1);
for (int i = 1; i < cnt; i++)
printf("%d+", num[i]);
printf("%d\n", num[cnt]);
}
return 0;
}

B.题意,有n个房子顺时针排成一圈,标号从1到n,只能顺时针走,要按次序到达规定的位置,从一个房子到旁边的房子需要1单位的时间,求总共要多长时间(注意要用64位整形)

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h> using namespace std; int a[100005]; int main()
{
int n, m;
__int64 ans;
a[0] = 1;
while (scanf("%d %d", &n, &m) != EOF)
{
ans = 0;
for (int i = 1; i <= m; i++)
{
scanf("%d", &a[i]);
if (a[i] >= a[i-1])
ans += (__int64)(a[i] - a[i-1]);
else
ans += (n-a[i-1]+a[i]);
}
printf("%I64d\n", ans);
}
return 0;
}

codeforces 339A.Helpful Maths B.Xenia and Ringroad 两水题的更多相关文章

  1. [ An Ac a Day ^_^ ] CodeForces 339A Helpful Maths

    熄灯了才想起来没写博客 赶紧水一道题碎觉…… #include<stdio.h> #include<iostream> #include<algorithm> #i ...

  2. Codeforces 339B:Xenia and Ringroad(水题)

    time limit per test : 2 seconds memory limit per test : 256 megabytes input : standard input output ...

  3. CodeForces 339B Xenia and Ringroad(水题模拟)

    题意:给定 n 个地方,然后再给 m 个任务,每个任务必须在规定的地方完成,并且必须按顺序完成,问你最少时间. 析:没什么可说的,就是模拟,记录当前的位置,然后去找和下一个位置相差多长时间,然后更新当 ...

  4. Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题

    除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃 ...

  5. Codeforces Testing Round #8 B. Sheldon and Ice Pieces 水题

    题目链接:http://codeforces.com/problemset/problem/328/B 水题~ #include <cstdio> #include <cstdlib ...

  6. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  7. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  8. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  9. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

随机推荐

  1. 【docker学习二】CentOS7.5+Docker 镜像(容器)的使用

    承接上篇:https://mp.csdn.net/postedit/82744127 上文介绍了容器与镜像的基本操作,这里总结下容器的使用. 先在官网找到一个镜像: https://hub.docke ...

  2. 【JVM】01虚拟机内存模型

    学习链接:https://blog.csdn.net/u010425776/article/details/51170118 博主整理的条理清晰,在这里先感谢博主分享 去年看视频学习写过一篇JVM的博 ...

  3. python爬取拉勾网数据并进行数据可视化

    爬取拉勾网关于python职位相关的数据信息,并将爬取的数据已csv各式存入文件,然后对csv文件相关字段的数据进行清洗,并对数据可视化展示,包括柱状图展示.直方图展示.词云展示等并根据可视化的数据做 ...

  4. Maven下载Jar包(bat脚本)

    1.创建一个bat文件叫download.bat 2.里面写入以下代码 call mvn -f pom.xml dependency:copy-dependencies 3.创建pom.xml文件 4 ...

  5. ZOJ 3962:Seven Segment Display(思维)

    https://vjudge.net/problem/ZOJ-3962 题意:有16种灯,每种灯的花费是灯管数目,代表0~F(十六进制),现在从x开始跳n-1秒,每一秒需要的花费是表示当前的数的花费之 ...

  6. 分享常见的HTTP状态码

    本内容摘抄自RUNOOB.COM 当浏览一个网页时,浏览器会向网页所在服务器发出请求.当浏览器确定接收并显示网页之前,此网页所在的服务器会返回一个含有HTTP状态码(HTTP Status Code) ...

  7. umeditor 上传图片 相对路径的设置和保存

    此篇文章仅献给已实现百度富文本编辑器,想要设置相对路径并保存到数据库,方便以后项目迁移. 使用的版本为1.2.3,适用图片上传中点击以及拖拽功能. //保存图片相对地址的设置        //1.请 ...

  8. scrapy实战2分布式爬取lagou招聘(加入了免费的User-Agent随机动态获取库 fake-useragent 使用方法查看:https://github.com/hellysmile/fake-useragent)

    items.py # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentati ...

  9. linux应用程序设计--Makefile工程管理

    Makefile文件描述了整个工程的编译.链接等规则.包括:工程中哪些源文件需要编译以及如何编译:需要创建哪些库文件以及如何创建这些库文件.如何产生最终的可执行文件. Makefile相关术语 1.规 ...

  10. Java volatile关键字小结

    public class Test { public static void main(String[] args){ } } /* 12.3 Java内存模型 Java内存模型定义了线程与主内存之间 ...