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 |
H2O题!#include <iostream> #include <cmath> #include <stdio.h> using namespace std; int main() { int m; scanf("%d", &m); double n_ = (-1+sqrt(1.0+8*m))/2; int n = (int) n_; if(abs(n_-n) > 1e-6) n++; for(int nn = n; ; nn++){ if((nn*(nn+1)/2-m)%2 == 0){ printf("%d\n", nn); break; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator