Skip to content

Instantly share code, notes, and snippets.

@ZeusAFK
Created November 10, 2012 13:16
Show Gist options
  • Save ZeusAFK/4051032 to your computer and use it in GitHub Desktop.
Save ZeusAFK/4051032 to your computer and use it in GitHub Desktop.
solucion a los problemas del WarmUp final latinoamericana ACM-ICPC
package acm2012;
import java.text.DecimalFormat;
import java.util.Scanner;
public class ACM2012 {
static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
A();
B();
}
static void A(){
while(true){
int H = in.nextInt();
int P = in.nextInt();
double avg = (double)H / (double)P;
DecimalFormat df = new DecimalFormat("#.##");
String result = df.format(avg).replace(',', '.');
if(!result.contains("."))
result += ".00";
System.out.println(result);
}
}
static void B(){
while(true){
int N = in.nextInt();
int result = 0;
boolean missing = false;
for(int i = 0; i < N; i++){
int x = in.nextInt();
if(x == 0){
if(missing){
result++;
missing = false;
}
else
missing = true;
}
else
missing = false;
}
System.out.println(String.valueOf(result));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment