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 |
数据太水了,建议增加数据。我这个暴力也A了。#include <stdio.h> #define SIZE 10000001 int b[SIZE]; int main() { //freopen("2140.txt","r",stdin); int i,j,n,tmp,cnt; scanf( "%d", &n ); cnt = 0; b[0] = 0; for (i = 1 ; i <= n ; i++) { b[i] = b[i - 1] + i; } for (i = n ; i >= 1 ; i--) { for (j = i - 1 ; j >= 0 ; j--) { tmp = b[i] - b[j]; if ( tmp == n ) { cnt++; } else if ( tmp > n ) { break; } } } printf( "%d\n", cnt ); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator