50,523
社区成员
发帖
与我相关
我的任务
分享
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
TreeMap hm=new TreeMap();
String[] nums=new String[3];
int count=scan.nextInt();
for(int i=0;i<count;i++){
Scanner scan1=new Scanner(System.in);
nums=scan1.next().split(" ");
if(!hm.containsKey(Integer.parseInt(nums[0])))
hm.put(Integer.parseInt(nums[0]), Integer.parseInt(nums[1]));
}
Collection coll=hm.keySet();
List list=new ArrayList(coll);
for(int i=0;i<list.size()-1;i++){
int m=Integer.parseInt(list.get(i).toString());
int n=Integer.parseInt(list.get(i+1).toString());
if(n-m!=1){
int cha=n-m-1;
int A=Integer.parseInt(hm.get(m).toString());
int B=Integer.parseInt(hm.get(n).toString());
for(int j=1;j<n-m;j++)
{
int value=(A+(B-A)/(n-m)*i);
hm.put(m+j, value);
}
}
}
Iterator it=hm.keySet().iterator();
while(it.hasNext())
{
Object key=it.next();
System.out.println(key+" "+hm.get(key));
}
}
}