Posts

Problem——50A. Domino piling——Codeforces

 /* ou are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions: Each domino completely covers two squares. No two dominoes overlap. Each domino lies entirely inside the board. It is allowed to touch the edges of the board. Find the maximum number of dominoes, which can be placed under these restrictions. Input In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16). Output Output one number — the maximal number of dominoes, which can be placed. */ #include <bits/stdc++.h> using namespace std; int main(){ long int n,m; while(cin >> n >> m){     cout << n*m/2 << endl; }     return 0; }

Next Round(codeforces)

/* "Contestant who earns a score equal to or greater than the  k -th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total of  n  participants took part in the contest ( n  ≥  k ), and you already know their scores. Calculate how many participants will advance to the next round. Input The first line of the input contains two integers  n  and  k  ( 1 ≤  k  ≤  n  ≤ 50 ) separated by a single space. The second line contains  n  space-separated integers  a 1 ,  a 2 , ...,  a n  ( 0 ≤  a i  ≤ 100 ), where  a i  is the score earned by the participant who got the  i -th place. The given sequence is non-increasing (that is, for all  i  from  1  to  n  - 1  the following condition is fulfilled:  a i  ≥  a i  + 1 ). Output Output the number of participants who advance to the next round. Examples */...

Team(codeforces)

 /* One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution. This contest offers  n  problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution. Input The first input line contains a single integer  n  ( 1 ≤  n  ≤ 1000 ) — the number of problems in the contest. Then  n  lines contain three integers each, each integer is either  0  or  1 . If the first number in the line equals  1 , then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the ...

Way Too Long Words(codeforces)

/* Sometimes some words like " localization " or " internationalization " are so long that writing them many times in one text is quite tiresome. Let's consider a word  too long , if its length is  strictly more  than  10  characters. All too long words should be replaced with a special abbreviation. This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes. Thus, " localization " will be spelt as " l10n ", and " internationalization » will be spelt as " i18n ". You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes. Input The first line contains an integer  n  ( 1 ≤  n  ≤ ...

Theatre Square(codeforces)

 /* Theatre Square in the capital city of Berland has a rectangular shape with the size  n  ×  m  meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size  a  ×  a . What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line:  n ,   m  and  a  ( 1 ≤   n ,  m ,  a  ≤ 10 9 ). Output Write the needed number of flagstones. */ Source code: #include <bits/stdc++.h> using namespace std; int main(){ unsigned long long n, m, a = 1; unsigned long long na, ma, res = 0;     scanf("%llu %llu %llu", &n, &m, &a);     na = n/a;     i...

first codeforces(A. Watermelon)

 #include <bits/stdc++.h> using namespace std; int main() {     int w;     scanf("%d",&w);     if(w%2==0 && w!=2)         {             printf("YES");         }     else         {             printf("NO");         }     return 0; }

Sieve Of Eratosthenes

  #include   <bits/stdc++.h> using   namespace   std ; //Sieve of Eratosthenes /** 1  Create a list of consecutive integers from 2 to n:     (2, 3, 4, …, n). 2  Initially, let p equal 2, the first prime number. 3  Starting from p2, count up in increments of p and mark    * each of these numbers greater than or equal to p2 itself   * in the list. These numbers will be    * p(p+1), p(p+2), p(p+3), etc.. 4  Find the first number greater than p in the list that    * is not marked. If there was no...