poj 2140的一种解法

 

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
                 int c=1;
     bool fg=0;
                 for(int i=1;i<=n/2;i++)
                 {
                         if(i%2==1)
                         {
                                   if(n%i==0) c++;
                         }
                         else if((i/2*(int(n/i)+(n/i)+1))==n&&fg) {c++;if (n/i==1) fg=1;}                        
                 }
     bool k=0;
                  k=(n%2==0);
                 cout<<c-k<<endl;                
    }   
    return 0;
}

 

你可能感兴趣的:(c,include)