Sicily1218

1579 단어
웨이에게 뇌장애를 주었어요. 계속 웨이를 줬어요.
#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]
",L[i],R[i]); if (M<=N) printf("[%d,%d]
",M,M); } return 0; }

좋은 웹페이지 즐겨찾기