2017.10.26 water question Major combat part of question solution, 2017.10.26 question Solution

Source: Internet
Author: User

2017.10.26 water question Major combat part of question solution, 2017.10.26 question Solution

 

I feel that this topic is beyond the outline of QWQ...

QWQ ......

A P2907 [usaco 08open] Roads Around The Farm

Why do I feel this question is not as difficult as getting started ..

This is my idea.

For each n, k

Solving a equations makes

X-y = kx −y = k

X + y = nx + y = n

Then perform similar operations on the obtained x and y respectively.

It looks simple,

But I am stuck with QWQ by precision ....

1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 # include <stdlib. h> 6 # include <ctime> 7 using namespace std; 8 const int MAXN = 0x7fffff; 9 const int INF = 50; 10 inline int read () 11 {12 char c = getchar (); int f = 1, x = 0; 13 while (c <'0' | c> '9 ') {if (c = '-') f =-1; c = getchar ();} 14 while (c> = '0' & c <= '9 ') x = x * 10 + c-48, c = getchar (); return x * f; 15} 16 int ans = 0; 17 void dfs (int n, int k) 18 {1 9 double p = (double) (n + k)/2; 20 double q = (double) n-(n + k)/2; 21 int o = (n + k)/2; 22 double l = p-(double) o; 23 if (l! = 0 | p> = n & q <= 0 | q> = n & p <= 0) 24 {25 ans ++; 26 return; 27} 28 dfs (p, k); dfs (q, k); 29} 30 int main () 31 {32 int n = read (), k = read (); 33 dfs (n, k); 34 printf ("% d", ans); 35 return 0; 36}View CodeB P1851 good friend

Affinity

Direct brute-force computing

1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 # include <stdlib. h> 6 # include <ctime> 7 # define LL long 8 using namespace std; 9 const ll maxn = 0x7fffff; 10 const ll inf = 50; 11 inline LL read () 12 {13 char c = getchar (); LL f = 1, x = 0; 14 while (c <'0' | c> '9 ') {if (c = '-') f =-1; c = getchar ();} 15 while (c> = '0' & c <= '9 ') x = x * 10 + c-48, c = getchar (); return x * f; 16} 17 int main () 18 {19 LL N = read (); 20 while (n ++) 21 {22 LL p = n; 23 LL tot = 0, tot2 = 0; 24 for (LL I = 1; I <p; I ++) if (p % I = 0) tot + = I; 25 for (LL I = 1; I <tot; I ++) if (tot % I = 0) tot2 + = I; 26 if (p = tot2 & p! = Tot) 27 {printf ("% lld", p, tot); exit (0) ;}28 29} 30 return 0; 31}View CodeC P1926 bookboy

01 backpack, calculate the maximum value and release time

Greedy calculation for the most frequently asked questions

1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 # include <stdlib. h> 6 # include <ctime> 7 # include <algorithm> 8 using namespace std; 9 const int MAXN = 151; 10 const int INF = 50; 11 inline int read () 12 {13 char c = getchar (); int f = 1, x = 0; 14 while (c <'0' | c> '9 ') {if (c = '-') f =-1; c = getchar ();} 15 while (c> = '0' & c <= '9 ') x = x * 10 + c-48, c = getchar (); return x * f; 16} 17 int n, m, r, k; 18 int dp [MAXN] [MAXN]; 19 // 0 time 20 // 1 score 21 int ti [MAXN]; 22 struct node23 {24 int time; 25 int val; 26} hw [MAXN]; 27 int main () 28 {29 n = read (); m = read (); k = read (); r = read (); 30 for (int I = 1; I <= n; I ++) ti [I] = read (); 31 for (int I = 1; I <= m; I ++) hw [I]. time = read (); 32 for (int I = 1; I <= m; I ++) hw [I]. val = read (); 33 for (int I = 1; I <= m; I ++) 34 for (int j = 0; j <= r; j ++) 35 if (j  

D P1496 burning Chibi

Sort by left endpoint

Maintain the leftmost and rightmost values

1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 # include <stdlib. h> 6 # include <ctime> 7 # include <algorithm> 8 # define LL long 9 using namespace std; 10 const ll maxn = 20001; 11 const ll inf = 50; 12 inline LL read () 13 {14 char c = getchar (); LL f = 1, x = 0; 15 while (c <'0' | c> '9') {if (c = '-') f =-1; c = getchar ();} 16 while (c> = '0' & c <= '9') x = x * 10 + c-48, c = getchar (); return x * f; 17} 18 struct node19 {20 LL bg, ed; 21} a [MAXN]; 22 LL n; 23 LL comp (const node & a, const node & B) 24 {25 return. bg <B. bg; 26} 27 LL ans; 28 LL nowleft, nowright; 29 int main () 30 {31 n = read (); 32 for (LL I = 1; I <= n; I ++) 33 {34 a [I]. bg = read (), a [I]. ed = read (); 35 if (a [I]. bg> a [I]. ed) swap (a [I]. bg, a [I]. ed); 36} 37 38 sort (a + 1, a + n + 1, comp); 39 nowleft = a [1]. bg, nowright = a [1]. ed; 40 a [n + 1]. bg = 1e10 + 10; 41 a [n + 1]. ed = 1e10 + 20; 42 for (LL I = 2; I <= n + 1; I ++) 43 {44 if (a [I]. bg <= nowright) nowright = max (nowright, a [I]. ed); 45 else46 {47 ans + = abs (nowright-nowleft); 48 nowleft = a [I]. bg; nowright = a [I]. ed; 49} 50} 51 printf ("% lld", ans); 52 return 0; 53}View Code

 

E P1302 visible rectangle will not do hahaha

 

 

 

 

 

 

# Include <iostream> # include <cstdio> # include <cstring> # include <cmath> # include <stdlib. h >#include <ctime> # define LL long usingnamespacestd; const ll maxn = 0x7fffff; const ll inf = 50; inline LL read () {char c = getchar (); LL f = 1, x = 0; while (c <'0' | c> '9') {if (c = '-') f =-1; c = getchar ();} while (c> = '0' & c <= '9') x = x * 10 + c-48, c = getchar (); return x * f;} int main () {LL n = read (); while (n ++) {LL p = n; LL tot = 0, tot2 = 0; for (L L I = 1; I <p; I ++) if (p % I = 0) tot + = I; for (LL I = 1; I <tot; I ++) if (tot % I = 0) tot2 + = I; if (p = tot2 & p! = Tot) {printf ("% lld", p, tot); exit (0) ;}} return0 ;}

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.