__________________________________
Method Ad Hoc class of problems:
(1) Mechanism analysis. Analysis subject description, launch algorithms.
(2) statistical analysis. Pursue the final mathematical model.
Problem 1:
Miracle Begins in 1960.
The n-th bits of k = 2 ^ (2+ (y-1960) / 10), can be placed in the k-bit unsigned integer is the largest (2 ^ k) -1, then we introduced a number of operations:
--------------https://vjudge.net/contest/317081#problem/A
code:
#include<stdio.h> #include<math.h> int main() { int year; int endflag; int n; double sum; while(scanf("%d",&year),year) { endflag=1<<((year-1960)/10+2);// 1<<a==pow(2,a) n=2; sum=0; while(sum<=endflag) { sum+=log(n)/log(2);//log2(n)! n++; } printf("%d\n",n-2); } return 0; }
Problem 2:
https://vjudge.net/contest/317081#problem/C
#include<iostream> #include<cstdio> using namespace std; int t,d,m,n,min_,max_; int main() { scanf("%d",&t); while(t--) { scanf("%d%d",&m,&n); min_=max_=0;//双双赋值! while(n--) { scanf("%d",&d); min_=max(min_,min(d,m-d)); max_=max(max_,max(d,m-d)); } printf("%d %d\n",min_,max_); } return 0; }