Topic Meaning:
http://acm.hdu.edu.cn/showproblem.php?pid=2058
Give N and M, in the number less than N, to find a continuous sequence, so that it and M, and from small to large output.
Topic Analysis:
See this question for the first time, on the simulation, obviously timed out, and later in the "Short Code of the United States" saw a good solution, and detailed explanation, now I will only use, do not know how to say understand, I am also drunk ...
AC Code:
/** * @xiaoran * * #include <iostream> #include <cstdio> #include <map> #include <cstring> #include <string> #include <algorithm> #include <queue> #include <vector> #include <stack># include<cstdlib> #include <cctype> #include <cmath> #define LL long longusing namespace std;struct node {int A, b;}; int main () {int n,m,a,b; while (cin>>n>>m) {if ((n+m) ==0) break; Stack<node> St; if (n>m) n=m; int i=0; while (m-i>0) {node nd; M-=++i; if (m%i==0) {a=m/i+1; B=a+i-1; Nd.a=a; Nd.b=b; cout<< "[" <<a<< "," <<b<< "]" <<endl; if (b<=n) St.push (ND); } if (b>n) break; } while (!st.empty ()) {cout<< "[" <<st.top () .a<< "," <<st.top () .b<< "]" <<e Ndl St.pop ();} cout<<endl; }return 0;}
HDU 2058 The sum problem (math problem)