Codeforces 467 (#267 (Div. 2) Problem Solving report

Source: Internet
Author: User
Tags bitset cmath

A: wa was drunk three times.

1 // file name:. CPP 2 // Author: darkdream 3 // created time: thursday, September 18, 2014, 43 seconds, 4 5 # include <vector> 6 # include <list> 7 # include <map> 8 # include <set> 9 # include <deque> 10 # include <stack> 11 # include <bitset> 12 # include <algorithm> 13 # include <functional> 14 # include <numeric> 15 # include <utility> 16 # include <sstream> 17 # include <iostream> 18 # include <iomanip> 19 # include <cstdio> 20 # include <cmath> 21 # include <cstdlib> 22 # include <cstring> 23 # include <ctime> 24 # define ll long long25 26 using namespace STD; 27 28 int main () {29 int N; 30 scanf ("% d", & N); 31 int sum = 0; 32 int ans = 0; 33 for (INT I = 1; I <= N; I ++) 34 {35 int A, B; 36 scanf ("% d", &, & B); 37 if (a <= B-2) 38 {39 ans ++; 40} 41} 42 printf ("% d \ n", ANS ); 43 return 0; 44}
View code

B: exclusive or

1 // file name: B. CPP 2 // Author: darkdream 3 // created time: thursday, September 18, 2014, 10 seconds, 4 5 # include <vector> 6 # include <list> 7 # include <map> 8 # include <set> 9 # include <deque> 10 # include <stack> 11 # include <bitset> 12 # include <algorithm> 13 # include <functional> 14 # include <numeric> 15 # include <utility> 16 # include <sstream> 17 # include <iostream> 18 # include <iomanip> 19 # include <cstdio> 20 # include <cmath> 21 # include <cstdlib> 22 # include <cstring> 23 # include <ctime> 24 # define ll long long25 26 using namespace STD; 27 int A [10005]; 28 int n, m, K; 29 int isok (int x) 30 {31 int T = 0; 32 While (X) 33 {34 if (X & 1) 35 {36 t ++; 37} 38 X >>= 1; 39} 40 if (T <= k) 41 return 1; 42 return 0; 43} 44 int main () {45 scanf ("% d", & N, & M, & K ); 46 for (INT I = 1; I <= m + 1; I ++) 47 {48 scanf ("% d", & A [I]); 49} 50 int num = (1 <n)-1; 51 int sum = 0; 52 for (Int J = 1; j <= m; j ++) 53 {54 int temp = A [M + 1] ^ A [J]; 55 if (isok (temp) 56 sum ++; 57} 58 59 printf ("% d \ n", sum); 60 return 0; 61}
View code

C: DP, DP [I] [k] = max (DP [I-1] [K], DP [I-m] [k-1] + sum [I]-sum [I-m])

1 // file name: B. CPP 2 // Author: darkdream 3 // created time: thursday, September 18, 2014, 10 seconds, 4 5 # include <vector> 6 # include <list> 7 # include <map> 8 # include <set> 9 # include <deque> 10 # include <stack> 11 # include <bitset> 12 # include <algorithm> 13 # include <functional> 14 # include <numeric> 15 # include <utility> 16 # include <sstream> 17 # include <iostream> 18 # include <iomanip> 19 # include <cstdio> 20 # include <cmath> 21 # include <cstdlib> 22 # include <cstring> 23 # include <ctime> 24 # define ll long long25 26 using namespace STD; 27 int A [10005]; 28 int n, m, K; 29 int isok (int x) 30 {31 int T = 0; 32 While (X) 33 {34 if (X & 1) 35 {36 t ++; 37} 38 X >>= 1; 39} 40 if (T <= k) 41 return 1; 42 return 0; 43} 44 int main () {45 scanf ("% d", & N, & M, & K ); 46 for (INT I = 1; I <= m + 1; I ++) 47 {48 scanf ("% d", & A [I]); 49} 50 int num = (1 <n)-1; 51 int sum = 0; 52 for (Int J = 1; j <= m; j ++) 53 {54 int temp = A [M + 1] ^ A [J]; 55 if (isok (temp) 56 sum ++; 57} 58 59 printf ("% d \ n", sum); 60 return 0; 61}
View code

 

Codeforces 467 (#267 (Div. 2) Problem Solving report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.