Codeforces Round #395 (Div. 2)(A.思维,B,水)

时间:2021-07-31 20:09:44

A. Taymyr is calling you

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist.

Ilia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes, i.e. in minutes m, 2m, 3m and so on. The day is z minutes long, i.e. the day consists of minutes 1, 2, ..., z. How many artists should be killed so that there are no artists in the room when Ilia calls? Consider that a call and a talk with an artist take exactly one minute.

Input

The only string contains three integers — n, m and z (1 ≤ n, m, z ≤ 104).

Output

Print single integer — the minimum number of artists that should be killed so that there are no artists in the room when Ilia calls.

Examples
Input
1 1 10
Output
10
Input
1 2 5
Output
2
Input
2 3 9
Output
1
Note

Taymyr is a place in the north of Russia.

In the first test the artists come each minute, as well as the calls, so we need to kill all of them.

In the second test we need to kill artists which come on the second and the fourth minutes.

In the third test — only the artist which comes on the sixth minute.

题目链接:http://codeforces.com/contest/764/problem/A

分析:此题竟然是求n与m的最小公倍数,我TM是智障了!试了三次,开始以为就是t/(m×n),智障宝宝!

不说太多,都是泪啊!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
}
int main()
{
int n,m,t;
while(cin>>n>>m>>t)
{
int x=gcd(n,m);
int y=n*m/x;
int z=t/y;
cout<<z<<endl;
}
return ;
}

B. Timofey and cubes

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.

In this time, Timofey's elder brother, Dima reordered the cubes using the following rule. Suppose the cubes are numbered from 1 to n in their order. Dima performs several steps, on step i he reverses the segment of cubes from i-th to (n - i + 1)-th. He does this while i ≤ n - i + 1.

After performing the operations Dima went away, being very proud of himself. When Timofey returned to his cubes, he understood that their order was changed. Help Timofey as fast as you can and save the holiday — restore the initial order of the cubes using information of their current location.

Input

The first line contains single integer n (1 ≤ n ≤ 2·105) — the number of cubes.

The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109), where ai is the number written on the i-th cube after Dima has changed their order.

Output

Print n integers, separated by spaces — the numbers written on the cubes in their initial order.

It can be shown that the answer is unique.

Examples
Input
7 
4 3 7 6 9 1 2
Output
2 3 9 6 7 1 4
Input
8 
6 1 4 2 5 6 9 2
Output
2 1 6 2 5 4 9 6
Note

Consider the first sample.

  1. At the begining row was [2, 3, 9, 6, 7, 1, 4].
  2. After first operation row was [4, 1, 7, 6, 9, 3, 2].
  3. After second operation row was [4, 3, 9, 6, 7, 1, 2].
  4. After third operation row was [4, 3, 7, 6, 9, 1, 2].
  5. At fourth operation we reverse just middle element, so nothing has changed. The final row is [4, 3, 7, 6, 9, 1, 2]. So the answer for this case is row [2, 3, 9, 6, 7, 1, 4].

题目链接:http://codeforces.com/contest/764/problem/B

分析:智障宝宝继续犯傻,看了半天,以为规律就是奇偶变换,结果样例都没过,再回头看了下题,傻了眼,原来就是每两项第i项和第n-i+1项交换!

智障宝宝第二摔!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int a[];
int main()
{
int n;
while(cin>>n)
{
for(int i=;i<=n;i++)
cin>>a[i];
for(int i=;i<=(n+)/;i+=)
{
swap(a[i],a[n-i+]);
}
for(int i=;i<=n-;i++)
cout<<a[i]<<" ";
cout<<a[n]<<endl;
}
return ;
}

Codeforces Round #395 (Div. 2)(A.思维,B,水)的更多相关文章

  1. Codeforces Round &num;367 &lpar;Div&period; 2&rpar; A&period; Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  2. Codeforces Round &num;603 &lpar;Div&period; 2&rpar; A&period; Sweet Problem&lpar;水&period;&period;&period;&period;&period;&period;&period;没做出来&rpar;&plus;C题

    Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...

  3. Codeforces Round &num;334 &lpar;Div&period; 2&rpar; A&period; Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  4. Codeforces Round &num;285 &lpar;Div&period; 2&rpar; A&comma; B &comma; C 水&comma; map &comma;拓扑

    A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  5. 【CF1256】Codeforces Round &num;598 &lpar;Div&period; 3&rpar; 【思维&plus;贪心&plus;DP】

    https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...

  6. Codeforces Round &num;143 &lpar;Div&period; 2&rpar; &lpar;ABCD 思维场&rpar;

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

  7. Codeforces Round &num;416 &lpar;Div&period; 2&rpar;&lpar;A&comma;思维题,暴力,B&comma;思维题,暴力&rpar;

    A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  8. Codeforces Round &num;533 &lpar;Div&period; 2&rpar; C&period;思维dp D&period; 多源BFS

    题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...

  9. Codeforces Round &num;539 &lpar;Div&period; 2&rpar; D 思维

    https://codeforces.com/contest/1113/problem/D 题意 将一个回文串切成一段一段,重新拼接,组成一个新的回文串,问最少切几刀 题解 首先无论奇偶串,最多只会切 ...

随机推荐

  1. 《征服 C 指针》摘录5:函数形参 和 空的下标运算符&lbrack;&rsqb;

    一.函数的形参的声明 C 语言可以像下面这样声明函数的形参: void func(int a[]) {     // ... } 对于这种写法,无论怎么看都好像要向函数的参数传递数组. 可是,在 C ...

  2. Java获取系统相关信息System&period;getProperty&lpar;&rpar;

    java.version Java 运行时环境版本 java.vendor Java 运行时环境供应商 java.vendor.url Java 供应商的 URL java.home Java 安装目 ...

  3. Redis中connect和pconnect的区别

    首先先介绍下connect和pconnect的区别.connect:脚本结束之后连接就释放了. pconnect:脚本结束之后连接不释放,连接保持在php-fpm进程中.所以使用pconnect代替c ...

  4. 代码中动态改变布局属性RelativeLayout&period;LayoutParams&period;addRule&lpar;&rpar;

    我们知道,在 RelativeLayout 布局中有很多特殊的属性,通常在载入布局之前,在相关的xml文件中进行静态设置即可. 但是,在有些情况下,我们需要动态设置布局的属性,在不同的条件下设置不同的 ...

  5. 用批处理修改hotst文件提示&OpenCurlyDoubleQuote;拒绝访问”解决方法

    执行批处理命令时出现“拒绝访问”情况,把路径地址改为系统路名变量即可: 如 提示拒绝访问: echo 127.0.0.1 www.dujinchi.com >> C:\Windows\Sy ...

  6. 二叉搜索树&lpar;BST&rpar;学习笔记

    BST调了一天,最后遍历参数错了,没药救了-- 本文所有代码均使用数组+结构体,不使用指针! 前言--BFS是啥 BST 二叉搜索树是基于二叉树的一种树,一种特殊的二叉树. 二叉搜索树要么是一颗空树, ...

  7. thinkphp5 Request请求类

    获取请求类的几种方式: 1.助手函数(严格不算ba ) input('post.name'): 2.$request=\think\Request::instance(); 3.控制器中必须继承Con ...

  8. List中存放字符串进行排序

    package com.bjpowernode.t03sort; import java.util.ArrayList;import java.util.Collections; /* * List中 ...

  9. Windows下如何使用Heroku

    1. 安装 进入https://devcenter.heroku.com/articles/heroku-cli#windows,选择对应版本安装 安装后使用heroku -v可检查版本号 2. 登陆 ...

  10. 取消IDEA中代码重复的检测