AOJ 2197 Sum of Consecutive Integers
こんにちは川です。
今回は、数を減算して、貪欲に確かめていっています。
#include <bits/stdc++.h>
using
namespace
std;
int
main() {
int
n;
while
(cin>>n,n){
int
ans=0;
for
(
int
i=n/2+1;i>1;i--)
for
(
int
j=i-1,now=i+j;j>0&&now<=n;j--,now+=j)
if
(now==n)ans++;
cout<<ans<<endl;
}
}