其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做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. MFC之CImageList(1)

    CImageList BOOL Create( int cx, int cy, UINT nFlags, int nInitial, int nGrow ); 其中各项参数的含义为:cx定义图像的宽度 ...

  2. promise使用的正确方式

    一开始恨不能理解下面的代码,为什么可以一直then下去,什么时候要直接return  xxx,什么时候return 一个promise,什么时候用Promise.resolve() function ...

  3. 有关图片上传的相关知识input type=file,HTML5的 input:file上传类型控制

    遇到项目,要求做一个影像系统,对于前端开发需要了解file的相关属性,以及如何开发.工欲善其事,必先利器嘛.度娘一阵子搜索,找资料.这年头,需要的是你解决问题的能力啊! 参考应用:https://ww ...

  4. ActiveMQ基础简介

    1. 什么是ActiveMQ ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线.ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现 ...

  5. python自学笔记之开源小工具:SanicDB介绍

    SanicDB 是为 Python的异步 Web 框架 Sanic 方便操作MySQL而开发的工具,是对 aiomysql.Pool 的轻量级封装.Sanic 是异步IO的Web框架,同时用异步IO读 ...

  6. Linux useradd userdel groupadd groupdel gpasswd(组成员管理) id groups

    添加用户 useradd [选项] 用户名 -u :指定UID标记号 -d:指定宿主目录,缺省为/home/用户名 -g:指定所属的基本组(组名或GID) -G: 指定所属的附加组(组名或GID) - ...

  7. [ZOJ 3076] Break Standard Weight

    题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5009 题意:给你两个数字,可以把其中一个拆成两个数字,计算这三个数字 ...

  8. vue.js 简介

    Vue.js是什么 Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的 渐进式框架.与其他重量级框架不同的是,Vue 采用自底向上增量开发的设计.Vue 的核心库只关注视图层 ...

  9. Apache代理技术

    Apache代理技术 apache代理分为正向代理和反向代理. 正向代理是一个位于客户端和原始服务器之间的服务器, 客户端通过代理服务器访问外部的 web, 需要在客户端的浏览器中设置代理服务器. 反 ...

  10. Vue-cli + express 构建的SPA Blog(采用前后端分离方案)

    为什么学习并使用Vue 1.发展趋势 最近这几年的前端圈子,由于戏台一般精彩纷呈,从 MVC 到 MVVM,你刚唱罢我登场. backbone,AngularJS 已成昨日黄花,reactjs 如日中 ...