Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么总OT,看代码

Posted by ring22 at 2006-04-20 15:57:35 on Problem 2800
#include <iostream>
#include <math.h>
using namespace std;

long long N,K;

int main()
{
 long long i,s,mid,start,end;
 cin >> N >> K;
 s = 0;
 if( N > K )
 {
  s += (N-K)*K;
  N = K;
 }
 mid = (long long)sqrt(N);
 for(start=N,i=K/N,end=K/(i+1);end >= mid;i++,start=K/i,end=K/(i+1))
  s += ((start - end)*(K%(end+1) + K%start))/2;
 for(i = start;i>=1;i--)
  s += K%i;
 cout << s << endl;
// cin >> s;
 return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator