Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2054 Accepted Submission(s): 1238
1 2 5 8 4 7 2 2 0 0
0 1 4 7 3 5 0 1 0 0 1 2
题意:中文题.....不说话.......
分析:题是基础题,但是要懂具体是怎么拿的,不懂的话.....就暴力嘛,这数据也不大嘛.....
#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 1e9; const int MOD = 1e9+7; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define N 50010 int gcd(int a,int b){return b?gcd(b,a%b):a;} int main() { int n,m,a,b,k; double x = (1 + sqrt(5.0))/2.0; while(scanf("%d%d",&a,&b),(a+b)) { if(a>b) swap(a, b); k = b-a; if(a==(int)(k*x)) cout<<0<<endl; else { cout<<1<<endl; for(int i=1; i<=a; i++) { n = a-i; m = b-i; k = m-n; if(n==(int)(k*x)) cout<<n<<" "<<m<<endl; } for(int i=b-1; i>=0; i--) { n = a; m = i; if(n>m) swap(n, m); k = m-n; if(n==(int)(k*x)) cout<<n<<" "<<m<<endl; } } } return 0; }
原文:http://blog.csdn.net/d_x_d/article/details/52124601