/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 90ms 11.156 MiB
#2 Accepted 90ms 11.32 MiB
#3 Accepted 90ms 11.176 MiB
#4 Accepted 91ms 11.375 MiB
#5 Accepted 91ms 11.375 MiB
#6 Accepted 90ms 11.504 MiB
#7 Accepted 90ms 11.125 MiB
#8 Accepted 91ms 10.977 MiB
#9 Accepted 89ms 11.312 MiB
#10 Accepted 90ms 11.281 MiB

Code

import java.util.Scanner;

public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();

        long N = sc.nextInt();

        s = s.replace(".", "");
        String [] str = s.split("\\+");

        long []num = new long[str.length];

        for(int i =0; i<str.length; i++){
            num[i] = Long.parseLong(str[i]);
        }
        
        long diff = 0;
        long rst = 0;

        if(num.length>1){
            diff = num[1] - num[0];
        }
        

        for(int i=0; i<N; i++){
            rst += num[0] + i*diff;
        }
     
        System.out.println(rst);

}
}

Information

Submit By
Type
Submission
Problem
P1231 Busy Friend
Contest
LUCC Presents Intra LU Junior Programming Contest - Replay
Language
Java 8 (OpenJDK 1.8.0_422)
Submit At
2025-09-02 17:14:55
Judged At
2025-09-02 17:14:55
Judged By
Score
100
Total Time
91ms
Peak Memory
11.504 MiB