| ||||||||||
| 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 | |||||||||
求助:2800,wrong answer我本地测试了一些数据,都通过了,我觉得应该没问题
大牛帮看看是怎么回事
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String line = stdin.readLine();
StringTokenizer st = new StringTokenizer(line);
int n = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
long result = 0;
if(n > k) {
result = (n-k)*k;
n = k-1;
}
for(int i=2;i<n+1;i++) {
int shang = k/i;
int in = k/shang;
if(in>n)
in = n;
int yu = k%i;
int num;
if((num = in-i+1) > 1){
result += yu*num +num*(num-1)*(-shang)/2;
i = in;
}else
result += yu;
}
System.out.println(result);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator