Description The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep". Nevertheless Shapur has to find weaknesses in the Roman army to…
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> #include <map> #include <vector> using namespace std; long long num[1000005]; long long fz[1000005]; long long xds[100…
题意: 给出一个数组,数组的每一个元素都是不一样的,求出对于3个数组下标 i, j, k such that i < j < k and ai > aj > ak where ax is the value at position x. 的个数 明显数组的值太大了 先离散化,然后就是简单的树状数组了 对于每一个i,只要统计i前面的数中比a[i]大的数的个数,和i后面的数中比a[i]小的数的个数即可 #include <cstdio> #include <cstri…
A. Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those intege…
Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接快速幂 代码 #include<bits/stdc++.h> using namespace std; long long quickpow(long long m,long long n,long long k) { long long b = 1; while (n > 0) { if…
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hacking skills to the test! You've been called upon to help crack enemy codes in the current war on... something or another. Anyway, the point is that yo…
C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should s…
A. Ultra-Fast Mathematician time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theo…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/output 1 s, 256 MB x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB x1462 C Vasya and String standard input/output 1 s, 256 MB x1393…
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3192 Accepted Submission(s): 371 Problem Description You are given a rooted tree of N nodes, labeled from 1 to N. To the ith node a non-negat…
Codeforces #261 D D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Parmida is a clever girl and she wants to participate in Olympiads this year. Of course s…