sasha

Chunga-Changa(CodeForces-1181A)

半城伤御伤魂 提交于 2020-03-12 07:56:46
A. Chunga-Changa time limit per test1 second memory limit per test512 megabytes inputstandard input outputstandard output Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called “chizhik”. One has to pay in chizhiks to buy a coconut now. Sasha and Masha are about to buy some coconuts which are sold at price zz chizhiks per coconut. Sasha has xx chizhiks, Masha has yy chizhiks. Each girl will buy as many coconuts as she can using only her money. This way each girl will buy an integer

A. Sasha and His Trip

﹥>﹥吖頭↗ 提交于 2020-01-25 20:53:10
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sasha is a very happy guy, that's why he is always on the move. There are nn cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from 11 to nn in increasing order. The distance between any two adjacent cities is equal to 11 kilometer. Since all roads in the country are directed, it's possible to reach the city yy from the city xx only if x<yx<y. Once Sasha decided to go on a trip around the country and to visit all

Codeforces Round 718C(维护矩阵的线段树)

空扰寡人 提交于 2019-12-03 13:21:23
C. Sasha and Array time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sasha has an array of integers a 1 ,  a 2 , ...,  a n . You have to perform m queries. There might be queries of two types: 1 l r x — increase all integers on the segment from l to r by values x ; 2 l r — find , where f ( x ) is the x -th Fibonacci number. As this number may be large, you only have to find it modulo 10 9  + 7 . In this problem we define Fibonacci numbers as follows: f (1) = 1 , f (2) = 1 , f ( x ) =  f ( x  - 1) +  f ( x  - 2) for all x  > 2 . Sasha

CF1024E Natasha, Sasha and the Prefix Sums――DP/数学(组合数)

匿名 (未验证) 提交于 2019-12-03 00:13:02
   CF1024E     代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std ; typedef long long ll ; const int maxn = 2004 , mod = 998244853 ; int n , m ; ll dp [ maxn ][ maxn ], f [ maxn ][ maxn ], C [ maxn << 1 ][ maxn << 1 ]; void init () { C [ 0 ][ 0 ] = 1LL ; for ( int i = 1 ; i <= n + m ; ++ i ) { C [ i ][ 0 ] = 1LL ; for ( int j = 1 ; j <= i ; ++ j ) C [ i ][ j ] = ( C [ i - 1 ][ j - 1 ] + C [ i - 1 ][ j ]) % mod ; } } int main () { scanf ( "%d%d" , & n , & m ); init (); for ( int i = 1 ; i <= m ; ++ i ) { f [ 0 ][ i ] = 1 ; for ( int j = 1 ; j <

#C++初学记录(set进阶#acm cf 190802 B. Subsegments)

*爱你&永不变心* 提交于 2019-11-25 21:21:39
B. Subsegments#set进阶 Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in , which Sasha coped with. For Sasha not to think that he had learned all, Stas gave him a new task. For each segment of the fixed length Sasha must find the maximum element of those that occur on the given segment exactly once. Help Sasha solve this problem. Input The first line contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n) — the number of array elements and the length of the segment. Then follow n