-
Notifications
You must be signed in to change notification settings - Fork 0
codingame
Kais NAFFOUTI edited this page Jun 11, 2018
·
1 revision
package test;
class Change{ long coin2 = 0; long bill5 = 0; long bill10 = 0;
public long getCoin2() {
return coin2;
}
public void setCoin2(long coin2) {
this.coin2 = coin2;
}
public long getBill5() {
return bill5;
}
public void setBill5(long bill5) {
this.bill5 = bill5;
}
public long getBill10() {
return bill10;
}
public void setBill10(long bill10) {
this.bill10 = bill10;
}
}
public class SolutionBillets {
static Change optimalChange(long s){
Change ch = new Change();
long div10 = s / 10;
long div5 = (s % 10)/5;
long div2 = ((s % 10) % 5)/2;
ch.setBill10( div10);
ch.setBill5(div5);
ch.setCoin2(div5);
return ch;
}
public static void main (String args[]){
long s = 77L;
Change m = SolutionBillets.optimalChange(s);
System.out.println("Coin(s) 2$ : "+m.coin2);
System.out.println("Coin(s) 5$ : "+m.bill5);
System.out.println("Coin(s) 10$ : "+m.bill10);
long result = m.coin2 + m.bill5 + m.bill10 * 10;
System.out.println("\nChange given = " + result );
}
}
@OPTIONS @Path("/getsample") public Response getOptions() { return Response.ok() .header("Access-Control-Allow-Origin", "*") .header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS") .header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build(); }
dans le web services
If non of this work, try to exchange the "" provided for "Access-Control-Allow-Origin" header with your custom domain where you access this resource. I.g. If you call this from http://localhost::8080 use something like this ("Access-Control-Allow-Origin", "http://localhost:8080") instead of asterisk ""