zoukankan      html  css  js  c++  java
  • Codeforces Round #467 (Div. 2)(ABC)

    A. Olympiad
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.

    As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:

    • At least one participant should get a diploma.
    • None of those with score equal to zero should get awarded.
    • When someone is awarded, all participants with score not less than his score should also be awarded.

    Determine the number of ways to choose a subset of participants that will receive the diplomas.

    Input

    The first line contains a single integer n (1 ≤ n ≤ 100) — the number of participants.

    The next line contains a sequence of n integers a1, a2, ..., an (0 ≤ ai ≤ 600) — participants' scores.

    It's guaranteed that at least one participant has non-zero score.

    Output

    Print a single integer — the desired number of ways.

    Examples
    Input
    Copy
    4
    1 3 3 2
    Output
    3
    Input
    Copy
    3
    1 1 1
    Output
    1
    Input
    Copy
    4
    42 0 0 42
    Output
    1
    Note

    There are three ways to choose a subset in sample case one.

    1. Only participants with 3 points will get diplomas.
    2. Participants with 2 or 3 points will get diplomas.
    3. Everyone will get a diploma!

    The only option in sample case two is to award everyone.

    Note that in sample case three participants with zero scores cannot get anything.

    实际就是找除了零以外出现了几个不同的数

     1 #include <iostream>
     2 
     3 using namespace std;
     4 int n;
     5 int vis[650];
     6 int main(){
     7     cin>>n;
     8     for(int i=0;i<n;i++){
     9         int x;
    10         cin>>x;
    11         vis[x]=1;
    12     }
    13     int sum=0;
    14     for(int i=1;i<=600;i++){
    15         sum+=vis[i];
    16     }
    17     cout<<sum<<endl;
    18     return 0;
    19 }
    B. Vile Grasshoppers
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.

    The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .

    Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.

    In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.

    Input

    The only line contains two integers p and y (2 ≤ p ≤ y ≤ 109).

    Output

    Output the number of the highest suitable branch. If there are none, print -1 instead.

    Examples
    Input
    Copy
    3 6
    Output
    5
    Input
    Copy
    3 4
    Output
    -1
    Note

    In the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.

    It immediately follows that there are no valid branches in second sample case.

    变相的求素数,类似。

     1 #include <iostream>
     2 
     3 using namespace std;
     4 
     5 int n,m;
     6 bool prime(int x){
     7     for(int i=2;i<=n&&i*i<=x;i++){
     8         if(x%i==0){
     9             return false;
    10         }
    11     }
    12     return true;
    13 }
    14 
    15 int main(){
    16     cin>>n>>m;
    17     for(int i=m;i>n;i--){
    18         if(prime(i)){
    19             cout<<i<<endl;
    20             return 0;
    21         }
    22     }
    23     cout<<"-1"<<endl;
    24     return 0;
    25 }
    C. Save Energy!
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on.

    During cooking, Julia goes to the kitchen every d minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. The stove switches on and off instantly.

    It is known that the chicken needs t minutes to be cooked on the stove, if it is turned on, and 2t minutes, if it is turned off. You need to find out, how much time will Julia have to cook the chicken, if it is considered that the chicken is cooked evenly, with constant speed when the stove is turned on and at a constant speed when it is turned off.

    Input

    The single line contains three integers k, d and t (1 ≤ k, d, t ≤ 1018).

    Output

    Print a single number, the total time of cooking in minutes. The relative or absolute error must not exceed 10 - 9.

    Namely, let's assume that your answer is x and the answer of the jury is y. The checker program will consider your answer correct if .

    Examples
    Input
    Copy
    3 2 6
    Output
    6.5
    Input
    Copy
    4 2 20
    Output
    20.0
    Note

    In the first example, the chicken will be cooked for 3 minutes on the turned on stove, after this it will be cooked for . Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for . Thus, after four minutes the chicken will be cooked for . Before the fifth minute Julia will turn on the stove and after 2.5 minutes the chicken will be ready .

    In the second example, when the stove is turned off, Julia will immediately turn it on, so the stove will always be turned on and the chicken will be cooked in 20 minutes.

    题目大意:炉子每过k分钟关掉,你每过d分钟去把炉子打开,炉子开着时,每分钟完成烧鸡的1/t,关着时,完成1/2t,求需要的用时.

    分析:一道比较繁琐的模拟题.关键是找出周期,也就是找到炉子第一次从关到开的状态所经过的时间. 先处理整个的循环节,然后再单独处理剩下的部分.

     

     1 #include <iostream>
     2 #define ll long long int
     3 
     4 using namespace std;
     5 
     6 ll n,m,t,cnt;
     7 double ans=0;
     8 
     9 void sovel1(){
    10     ll all = n*2+m-n;
    11     ll a = cnt/all;
    12     ll b = cnt%all;
    13     ans +=a*m;
    14     if(b<=n*2){
    15         double an = b/2.0;
    16         ans += an;
    17     }else{
    18         double an =(b-n*2);
    19         ans+=n;
    20         ans+=an;
    21     }
    22 }
    23 
    24 void sovel2(){
    25     ll an = n/m;
    26     ll bn = n%m;
    27     ll all;
    28     if(bn==0){
    29         all = n*2;
    30         ans = (double)(cnt/2.0);
    31         return ;
    32     }
    33     else{
    34         all = n*2+(m-bn);
    35         ll xn = cnt/all;
    36         ll yu =cnt%all;
    37         ans +=(n+(m-bn))*xn;
    38         if(yu<=n*2){
    39             ans+=yu/2.0;
    40             return ;
    41         }else{
    42             ans+=n;
    43             yu-=n*2;
    44             ans+=yu;
    45         }
    46     }
    47 }
    48 int main(){
    49     cin>>n>>m>>t;
    50     cnt = t*2;
    51     if(n<=m){
    52         sovel1();
    53     }else{
    54         sovel2();
    55     }
    56     printf("%.1lf
    ",ans);
    57     return 0;
    58 }

     

     

  • 相关阅读:
    [基础架构]PeopleSoft都有哪些进程运行在进程服务器上
    [基础架构]PeopleSoft Process Scheduler 重要文件说明
    .NET Core微服务之基于Consul实现服务治理
    .net core3.1 Filter四种注入方式和异常过滤器
    ASP.NET Core配置监听URLs的六种方式
    Asp.Net Core中JWT刷新Token解决方案
    ASP.NET Core-ActionFilter实现依赖注入(ServiceFilterAttribute 、TypeFilterAttribute) 【转】
    asp.net core 3.1配置log4net
    使用 Certbot 安装 Letsencrypt 证书
    使用新版 winsw 注册 windows 系统服务无法启动及停止问题
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/8490699.html
Copyright © 2011-2022 走看看