Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
纪念进7000,留代码思路如下#include<iostream> using namespace std; int main() { int n,x,count; cin>>x; count=0; for(n=1;n*(n+1)/2<=x;n++) { if((x-n*(n+1)/2)%n==0) { count++; } } cout<<count; return 0; } 思路: 比如说21: 21=21=1+1*(21-sum(1)/1; 21=10+11=(1+2)+2*(21-sum(2))/2; 21=6+7+8=(1+2+3)+3*(21-sum(3))/3; 21=1+2+3+4+5+6=(1+2+3+4+5+6)+6*(21-sum(6))/6; 所以只要判断x-sum(n)是否除尽n,满足一次,count+1; Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator