Sicily1218

给WA脑残了,一直WA。

#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int N,M;
    while (scanf("%d",&N)!=EOF)
    {
        scanf("%d",&M);
        int counter=0;
        int L[100000],R[100000];
        int div=2;
        int left,right;
        while (1)
        {
            if (div%2==0)
            {
                if (M%div==0.5*div)
                {
                    left=M/div-(div/2-1);
                    right=M/div+(div/2);
                    if (left>=1 && right<=N)
                    {
                        L[counter]=left;
                        R[counter]=right;
                        counter++;
                    }
                    else
                        break;
                }
            }
            else
            {
                if (M%div==0)
                {
                    left=M/div-div/2;
                    right=M/div+div/2;
                    if (left>=1 && right<=N)
                    {
                        L[counter]=left;
                      R[counter]=right;
                        counter++;
                }
                  else
                      break;
                }
            }
            div++;
        }
        int i;
        for (i=counter-1;i>=0;i--)
            printf("[%d,%d]\n",L[i],R[i]);
        if (M<=N)
            printf("[%d,%d]\n",M,M);
    }
    return 0;
}                                     


你可能感兴趣的:(Sicily1218)