其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念。

B - B

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the owner of the account owes the bank money.

Ilya the Lion has recently had a birthday, so he got a lot of gifts. One of them (the gift of the main ZooVille bank) is the opportunity to delete the last digit or the digit before last from the state of his bank account no more than once. For example, if the state of Ilya's bank account is -123, then Ilya can delete the last digit and get his account balance equal to -12, also he can remove its digit before last and get the account balance equal to -13. Of course, Ilya is permitted not to use the opportunity to delete a digit from the balance.

Ilya is not very good at math, and that's why he asks you to help him maximize his bank account. Find the maximum state of the bank account that can be obtained using the bank's gift.

Input

The single line contains integer n (10 ≤ |n| ≤ 109) — the state of Ilya's bank account.

Output

In a single line print an integer — the maximum state of the bank account that Ilya can get.

Sample Input

Input
2230
Output
2230
Input
-10
Output
0
Input
-100003
Output
-10000

输入一个整数(可正可负)可以改变最后一位数或者倒数第二个数,使这个数最大。

 #include<stdio.h>
int main()
{
int acc;
int new1,new2;
scanf("%d",&acc);
if(acc >= )printf("%d",acc);
else
{
new1 = acc/;
new2 = new1/ * +(acc - new1 * );
if(new1 > new2)printf("%d",new1);
else printf("%d",new2);
}
return ;
}
C - C

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.

You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≤ li < ri ≤ n). The answer to the query li, ri is the number of such integers i (li ≤ i < ri), thatsi = si + 1.

Ilya the Lion wants to help his friends but is there anyone to help him? Help Ilya, solve the problem.

Input

The first line contains string s of length n (2 ≤ n ≤ 105). It is guaranteed that the given string only consists of characters "." and "#".

The next line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integers li, ri (1 ≤ li < ri ≤ n).

Output

Print m integers — the answers to the queries in the order in which they are given in the input.

Sample Input

Input
......
4
3 4
2 3
1 6
2 6
Output
1
1
5
4
Input
#..###
5
1 3
5 6
1 5
3 6
3 4
Output
1
1
2
2
0
 有一个由#.组成的字符串输入一对数a,b输出在字符串中从a到b连续相同的字符个数。不过这个题一个值得注意的地方是字符串存入的时候就要找出到目前为止的结果,这样读入数据的时候直接输出就行,不然会超时。
 #include<stdio.h>
#include<string.h>
char a[];
int b[];
int main()
{ int n,x,y,i,j,len;
scanf("%s",a);
len = strlen(a);
for(i = ;i < len;i++)
{
if(a[i-]== a[i])
b[i] = b[i - ]+;
else
b[i] = b[i - ];
}
scanf("%d",&n);
while(n--)
{
scanf("%d%d",&x,&y);
printf("%d\n",b[y-] - b[x-] );
}
return ;
}
D - D

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.

He's got a square 2n × 2n-sized matrix and 4n integers. You need to arrange all these numbers in the matrix (put each number in a single individual cell) so that the beauty of the resulting matrix with numbers is maximum.

The beauty of a 2n × 2n-sized matrix is an integer, obtained by the following algorithm:

  1. Find the maximum element in the matrix. Let's denote it as m.
  2. If n = 0, then the beauty of the matrix equals m. Otherwise, a matrix can be split into 4 non-intersecting 2n - 1 × 2n - 1-sized submatrices, then the beauty of the matrix equals the sum of number m and other four beauties of the described submatrices.

As you can see, the algorithm is recursive.

Help Ilya, solve the problem and print the resulting maximum beauty of the matrix.

Input

The first line contains integer 4n (1 ≤ 4n ≤ 2·106). The next line contains 4n integers ai (1 ≤ ai ≤ 109) — the numbers you need to arrange in the 2n × 2n-sized matrix.

Output

On a single line print the maximum value of the beauty of the described matrix.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64dspecifier.

Sample Input

Input
1
13
Output
13
Input
4
1 2 3 4
Output14
有4的n次方个数排成一个矩阵,求所有最美的数的和,可以对矩阵进行重新排列,使得最美的数的和最大。找出最美的数的规则是把矩阵分成四个2的n次方的矩阵,如果n==0最美的数就是他自己,否则是小矩阵中最大的数。没有用longlong,wa了几次。做法是:既然要找最大的和就把大的数分配给每个小矩阵,这样和就等于所有的和再加上后n=n/4个数的和,一直加到n==1.

 #include<iostream>
#include<algorithm>
using namespace std;
long long int a[];
long long int sum = ;
int main()
{ int N,n,i,j,k,m = ;
cin >> N;
n = N;
while(n != )
{
n = n/;
m++;
}
for(i = ;i < N;i++)
{
cin >> a[i];
sum += a[i];
}
sort(a,a+N);
for(i = N/;i >= ;i= i/)
{
for(j = N-;j >= N--i+;j--)
sum += a[j];
}
cout << sum;
return ; }

A - A

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

A median in an array with the length of n is an element which occupies position number  after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is the number 2, and a median of array (0, 96, 17, 23) — the number 17.

We define an expression  as the integer part of dividing number a by number b.

One day Vasya showed Petya an array consisting of n integers and suggested finding the array's median. Petya didn't even look at the array and said that it equals x. Petya is a very honest boy, so he decided to add several numbers to the given array so that the median of the resulting array would be equal to x.

Petya can add any integers from 1 to 105 to the array, including the same numbers. Of course, he can add nothing to the array. If a number is added multiple times, then we should consider it the number of times it occurs. It is not allowed to delete of change initial numbers of the array.

While Petya is busy distracting Vasya, your task is to find the minimum number of elements he will need.

Input

The first input line contains two space-separated integers n and x (1 ≤ n ≤ 500, 1 ≤ x ≤ 105) — the initial array's length and the required median's value. The second line contains n space-separated numbers — the initial array. The elements of the array are integers from 1 to 105. The array elements are not necessarily different.

Output

Print the only integer — the minimum number of elements Petya needs to add to the array so that its median equals x.

Sample Input

Input
3 10
10 20 30
Output
1
Input
3 4
1 2 3
Output
4

Hint

In the first sample we can add number 9 to array (10, 20, 30). The resulting array (9, 10, 20, 30) will have a median in position , that is, 10.

In the second sample you should add numbers 4, 5, 5, 5. The resulting array has median equal to 4.

有一个数组(任意顺序要从小到大排序)和一个数,改变这个数组,要使这个数处于数组中间位置,输出改变的次数。

交了不对,也把代码贴上,再贴几个大神的代码。

 #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[] = {-};
int n,i,j,m,num = ,x,y;
cin >> n >> m;
for(i = ;i <= n;i++)
{
cin >> a[i];
}
sort(a,a+n);
for(i = ;i <= n;i++)
{
if(a[i] <= m)
{
if(a[i] == m && i == (n+)/)
{
cout << << endl;
return ;
}
else continue;
}
else break;
}
x = i - ;
y = n - i + ;
num = (x < y)? y - x:x - y;
if((n + num)/ == i)
cout << num ;
else cout << num+;
return ;
}
 
 大神的
 #include<stdio.h>
int data[]; int d(double x); int main(void)
{
int n,x;
while(scanf("%d%d",&n,&x)!=-)
{
int bigger=;
int smaller=;
int counter=;
for(int i=;i<n;i++)
{
scanf("%d",&data[i]);
if(data[i]>x)
{
bigger++;
}
if(data[i]<x)
{
smaller++;
}
if(data[i]==x)
{
counter++;
}
}
if(smaller<d(n)&&smaller+counter>=d(n))
{
printf("0\n");
}
else if(smaller<counter+bigger)
{
printf("%d\n",bigger-smaller-counter);
}
else
{
printf("%d\n",smaller-bigger+-counter);
}
//printf("bigger: %d, smaller: %d, counter: %d, \n",bigger,smaller,counter);
}
return ;
} int d(double x)
{
return (int)(x+)*1.0/2.0;
}


 
 

OUC_Summer Training_ DIV2_#9 719的更多相关文章

  1. OUC_Summer Training_ DIV2_#16 725

    今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...

  2. OUC_Summer Training_ DIV2_#13 723afternoon

    A - Shaass and Oskols Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

  3. OUC_Summer Training_ DIV2_#12(DP1) 723

    这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS     Memory Limit:32768KB   ...

  4. OUC_Summer Training_ DIV2_#14 724

    又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS     Memory Limit:262144KB     64bit IO F ...

  5. OUC_Summer Training_ DIV2_#2之解题策略 715

    这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...

  6. OUC_Summer Training_ DIV2_#7 718

    是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS     Memory ...

  7. OUC_Summer Training_ DIV2_#11 722

    企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &am ...

  8. OUC_Summer Training_ DIV2_#5

    这是做的最好的一次了一共做了4道题  嘻嘻~ A - Game Outcome Time Limit:2000MS     Memory Limit:262144KB     64bit IO For ...

  9. OUC_Summer Training_ DIV2_#4之数据结构

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS     Me ...

随机推荐

  1. 01 Go之环境搭建

    1.1 Linux搭建Go环境 1.ssh远程登录Linux服务器,可选用iTerm.xshell ssh root@ip 2.建议配置好阿里云yum源.epel源 安装git yum install ...

  2. vue axios异步请求django

    1,配置请求路径 (1),vue中的请求路径要与django视图路径相同. (2),vue中的路由路径也要和django视图路径相同,比如视图路径为127.0.0.1:8000:home/index, ...

  3. js扩展Date对象的方法,格式化日期格式(prototype)

    扩展:Date.prototype.format = function(format){     var o =  {     "M+" : this.getMonth()+1, ...

  4. Vue-Cli项目如何查看依赖调用关系?

    Vue是个优秀的前端框架,不管是前端还是后端开发人员都能很快使用Vue来开发应用.但是随着项目开发的深入,组件之间的依赖就变得越来越多,耦合越来越严重.这时候我们迫切地需要分析下组件和依赖之间的调用关 ...

  5. idea tomcat 乱码问题的解决及相关设置

    问题,在idea中出现乱码问题,以前没有的,好像在设置系统代码为utf8之后就出现了,于是尝试了一系列办法,希望这些办法对您有帮助. 先看一下乱码的样式. 设置办法 1.在tomcat Server中 ...

  6. MySql学习笔记【二、库相关操作】

    命令规范 关键字.函数名称大写 数据库.表名.字段名小写 语句须以分号结尾 切换使用数据库 USE database_name 如:USE test 查看数据库列表 SHOW {DATABASES|S ...

  7. 原创博客>>>解决粘包问题的方法

    目录 原创博客>>>解决粘包问题的方法 原创博客>>>解决粘包问题的方法 服务端: import socket import struct service=sock ...

  8. deep_learning_Function_list变量前面加星号,字典变量前面加两个星号

    列表前面加星号作用是将列表解开成两个独立的参数,传入函数, 字典前面加两个星号,是将字典解开成独立的元素作为形参. def add(a, b): return a+b data = [4,3] pri ...

  9. python基础编程: 函数示例、装饰器、模块、内置函数

    目录: 函数示例 装饰器 模块 内置函数 一.函数示例: 1.为什么使用函数之模块化程序设计: 不使用模块程序设计的缺点: 1.体系结构不清晰,可主读性差: 2.可扩展性差: 3.程序冗长: 2.定义 ...

  10. 06-char,varchar和nvarchar三者的区别

    总结: 1.首先先知道一下SQLServer中数据存储的基本单位是页.每页的大小是8KB: 2.char(n),里面的n用于定义字符串长度,以字节为单位: 3.三者的区别 * char: 是定长的,比 ...