传送门: 2018 牛客网暑期 ACM 多样训练营(第五场)A gpa

Description

题目描述

At the university where she attended, the final score of her is ${\sum{s[i]c[i]} \over \sum{s[i]}}$

Now she can delete at most k courses and she want to know what the highest final score that can get.

阅读全文 »

D. MUH and Cube Walls

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

Description

Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights.

阅读全文 »

F. String Compression

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

Description

Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.

Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.

阅读全文 »

C. Socks

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

Description

Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy’s clothes.

阅读全文 »

D. Inversion Counting

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

Description

A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a**i < *a**j*. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3).

阅读全文 »

F. SUM and REPLACE

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

Description

Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1, 2, 3 and 6).

阅读全文 »

D. Mishka and Interesting sum

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

Description

Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, …, an of n elements!

阅读全文 »

夜雨寄北

李商隱

君問歸期未有期,巴山夜雨漲秋池。
何當共剪西窗燭,卻話巴山夜雨時。

最近训练时敲代码总爱在 if 语句中有位算符时踩坑, 比如 if(i&1==0)if(i&i-1 == 0),本意是想判 i 是否为偶数和 i 是否为 2 的幂,但这么写都是错误的,导致程序不能输出正确结果。每次 debug 时又不明所以,耗了很长时间才找到。在这里记录下。

错误的原因是 == 运算符优先级要高于 & | ^ 这三个位运算符,故导致上面代码的判断顺序实际为 if(i & (1==0))if(i & (i-1 == 0))。 很痛苦呀,有没有。

建议:

  • 判断式中如果同时存在位运算符小于等于大于时,将位运算符表达式加上括号
  • 判等时,如果一边是常数一边是变量,将常数放于判等左边。 (TAT,当时听郝斌老师讲这条时还不以为意,心想判等自己肯定不会写成 = , 现在想来,真是内牛满面呀,这条规则实在太好了)

臨江仙 送錢穆父

蘇軾

一別都門三改火,天涯踏盡紅塵。依然一笑作春溫。無波真古井,有節是秋筠。 惆悵孤帆連夜發,送行淡月微雲。樽前不用翠眉顰。人生如逆旅,我亦是行人。
0%