ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1091. Тмутараканские экзамены

Accepted Java
Послано magzhan 22 июн 2011 22:14

import java.math.BigInteger;
import java.util.*;

public class Problem {

    public static BigInteger c(int n, int k){
        BigInteger r=BigInteger.ONE;
        for(int i=0;i<k;i++){
            r=r.multiply(BigInteger.valueOf(n-i));
        }
        for(int i=0;i<k;i++){
            r=r.divide(BigInteger.valueOf(i+1));
        }
        return r;
    }

    public static boolean inP(int x, int[] p){
        for(int i=0;i<p.length;i++){
            if(p[i]==x)
                return true;
        }
        return false;
    }

    public static void main (String[] args) {
        try {

            Scanner in = new Scanner(System.in);

            int k=in.nextInt();
            int s=in.nextInt();

            int[] p = new int[9];
            boolean[] b = new boolean[s+1];

            BigInteger q = BigInteger.ZERO;

            p[0]=2;p[1]=3;p[2]=5;
            p[3]=7;p[4]=11;p[5]=13;
            p[6]=17;p[7]=19;p[8]=23;

            int x=0,y=0;
            int[] w = new int[s+1];
            for(int i=0;i<9;i++){
                x=0;y=s/p[i];
                for(int j=2;j<=s;j++){
                    if(j%p[i]==0){
                        if(b[j]){
                            for(int o=2;o<=j;o++){
                                if(j%o==0 && o<p[i] && inP(o,p)){
                                    w[o]++;
                                }
                            }
                        }
                        b[j]=true;
                    }
                }
                if(y>=k){
                    q=q.add(c(y,k));
                }
                for(int j=0;j<s+1;j++){
                    if(w[j]>=k){
                        q=q.subtract(c(w[j],k));
                    }
                }
                w=new int[s+1];

            }

            if(Integer.parseInt(q.toString())<=10000){
                System.out.println(q);
            }else{
                System.out.println(10000);
            }

        } catch (Exception ex) {

            System.out.println(ex.toString());
        }
    }
}
Re: Accepted Java
Послано Juliet 27 июн 2011 14:50
Apply the GOOD JOB for College ACMers to Make Large Money and Become a Millionaire

Hello, We need large no. of dedicated and hard working ACMers. The payment is good so we need ACMers to be efficient. All you have to do to get the job is to sign up at our websites. The link of our websites are given below.

http://www.PaisaLive.com/register.asp?3556638-4847933

After the registration, a confirmation email will be sent to your specified email address. Please click on the link inside the confirmation email to activate your account and recieve ACM work instantly. For any other queries you can mail the administrator.

Miss Juliet

Admin paisalive.com