package zhishu; import java.util.Scanner; import org.omg.CORBA.SystemException; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int result=0; int num=scanner.nextInt(); int max=num/2; int []zhishuji={2,3,5,7}; if(num<=10) { for(int i=0;i<=2;i++) { for(int j=0;j<4;j++) { if(num-zhishuji[i]==zhishuji[j]) { result++; } } } System.out.println(result); return; } for(int i=0;i<4;i++) { if((num-zhishuji[i])%2!=0&&(num-zhishuji[i])%3!=0&&(num-zhishuji[i])%5!=0&&(num-zhishuji[i])%7!=0) { //System.out.println(num-zhishuji[i]); result++; } } for(int i=2;i<=max;i++) { if(i%2!=0&&i%3!=0&&i%5!=0&&i%7!=0) { if((num-i)%2!=0&&(num-i)%3!=0&&(num-i)%5!=0&&(num-i)%7!=0) { //System.out.println(num-i); result++; } } } System.out.println(result); } }
//scala //定义基本实体 //价格 case class Price(price : Double) extends AnyVal //商品 case class Commodity(id : String , name : String , price: Price ) //客户 case class Customer(id : String , name : String) import java.util.Date //订单 class Order( customerId : String , commodityId : String , time : Date ) //定义数据 var users = List[Customer]() var goods = List[Commodity]() var orders = List[Order]() /** * 新增订单 * @param user * @param commodity */ def makeOrder(user : Customer , commodity: Commodity) = orders = new Order(user.id , commodity.id , new Date) :: orders /** * 查询 */ def allCustomer = users foreach(println) def allCommodity = goods foreach(println) def allOrders = orders foreach(println) /** * 增加数据 * @param obj * @tparam U */ def add[U](obj : U): Unit ={ obj match{ case Commodity => goods = obj.asInstanceOf[Commodity] :: goods case Customer => users = obj.asInstanceOf[Customer] :: users } }