You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

823 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

题目分析

  • 一年中有52个星期, 7 * 52 = 364
  • 星期一:x
  • 星期二:x+k
  • 星期三:x+2k
  • 星期四:x+3k
  • 星期五:x+4k
  • 星期六:x+5k
  • 星期日:x+6k
  • 目标是筹集n

问题:xk是怎么样来取值的?输出 x 尽可能大k 尽可能小的

1<=x<=100,k>=1

思考:

n=52\times (x+ (x+k) +(x+2k)+(x+3k)+(x+4k)+(x+5k)+(x+6k)) \\
\Leftrightarrow \\
n=52 \times (7x+21k)
for(int x=100;x>=1;x--){
  for(int k=1;52 * (7 * x + 21 * k) <= n;k++){
    if(n==52*(7*x+21*k))
      {
        cout<<x<<endl;
        cout<<k<<endl;
        exit(0);
      }
  }
}

已知x>=1,y>=1,且x+y=5x=?,y=?

显然:x<=4,y<=4

1<=x<=4,1<=y<=4

(1)x=1,y=4 (2)x=2,y=3 (3)x=3,y=2 (4)x=4,y=1