Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-12751
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4604
Code:
import java.util.*;
public class Uva_12751 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int s=0;
for(int cases=1;cases<=a;cases++){
int b=in.nextInt();
int k=in.nextInt();
int x=in.nextInt();
int rem=0;
for(int c=0;c<k;c++){
rem=rem+x;
x++;
}
s=(b*(b+1))/2;
System.out.println("Case "+cases+": "+(s-rem));
}
}
}
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-12751
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4604
Code:
import java.util.*;
public class Uva_12751 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int s=0;
for(int cases=1;cases<=a;cases++){
int b=in.nextInt();
int k=in.nextInt();
int x=in.nextInt();
int rem=0;
for(int c=0;c<k;c++){
rem=rem+x;
x++;
}
s=(b*(b+1))/2;
System.out.println("Case "+cases+": "+(s-rem));
}
}
}
No comments:
Post a Comment