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. Storm 学习之路(三)—— Storm单机版本环境搭建

    1. 安装环境要求 you need to install Storm’s dependencies on Nimbus and the worker machines. These are: Jav ...

  2. spring 5.x 系列第16篇 —— 整合dubbo (代码配置方式)

    文章目录 一. 项目结构说明 二.项目依赖 三.公共模块(dubbo-ano-common) 四. 服务提供者(dubbo-ano-provider) 4.1 提供方配置 4.2 使用注解@Servi ...

  3. mvc中的表现和数据分离怎么理解?

    使用过 JavaScript框架(如 AngularJS, Backbone)的人都很熟悉在UI(用户界面,前端)中mvc的工作机理.这些框架实现了MVC,使得在一个单页面中实现根据需要变化视图时更加 ...

  4. Method com/mysql/jdbc/PreparedStatement.isClosed()Z is abstract 报错解决

    java.lang.AbstractMethodError: Method com/mysql/jdbc/PreparedStatement.isClosed()Z is abstract ----- ...

  5. 深扒那些艺术的CSS

    概览 使用单个div做css绘图,会充分利用到: before.after伪元素 使用border-radius.border来控制图形的形状. 使用叠加的box-shadow来创建多个相同的形状(可 ...

  6. 源码阅读 - java.util.concurrent (四)CyclicBarrier

    CyclicBarrier是一个用于线程同步的辅助类,它允许一组线程等待彼此,直到所有线程都到达集合点,然后执行某个设定的任务. 举个例子:几个人约定了某个地方集中,然后一起出发去旅行.每个参与的人就 ...

  7. Spring 注解编程之注解属性别名与覆盖

    前两篇文章咱聊了深入了解了 Spring 注解编程一些原理,这篇文章我们关注注解属性方法,聊聊 Spring 为注解的带来的功能,属性别名与覆盖. 注解属性方法 在进入了解 Spring 注解属性功能 ...

  8. 利用Jmeter模拟Github登录

    最近学习了Jmeter的简单操作,很想找点东西来实战一下,因为我之前写过一篇通过Python模拟登录的文章,于是便想尝试下学习通过Jmeter来模拟登录. 本人环境:Jmeter5.1.1 关于Git ...

  9. Node热部署插件

    一.supervisor 首先需要使用 npm 安装 supervisor(这里需要注意一点,supervisor必须安装到全局) $ npm install -g supervisor Linux ...

  10. Java是如何实现平台无关性的

    相信对于很多Java开发来说,在刚刚接触Java语言的时候,就听说过Java是一门跨平台的语言,Java是平台无关性的,这也是Java语言可以迅速崛起并风光无限的一个重要原因.那么,到底什么是平台无关 ...