zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 084

    AtCoder Beginner Contest 084

    题目链接:https://abc084.contest.atcoder.jp/

    总结:2017年的最后一场ATC,只过了AB题,全程卡D,算法没问题,比赛时候的输出方式会WA。。

    A题题解:签到题,直接输出48-N即可。

    AC代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<algorithm>
     5 #include<cmath>
     6 using namespace std;
     7 
     8 int n,m;
     9 int main()
    10 {
    11     cin>>n;
    12     cout<<48-n<<endl;
    13     return 0;
    14 }

    B题题解:判断第A+1个是不是‘-’和其他的是不是数字即可。

    AC代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<algorithm>
     5 #include<cmath>
     6 using namespace std;
     7 int n,m;
     8 char s[15];
     9 int main()
    10 {
    11     cin>>n>>m;
    12     int ok = 1;
    13     int sum2 = 0;
    14     for(int i=1;i<=n+m+1;i++)
    15     {
    16         char x;
    17         cin>>x;
    18         if(i==n+1)
    19         {
    20             if(x!='-')ok = 0;
    21         }
    22         else if(x>='0'&&x<='9')sum2++;
    23     }
    24     if(ok==1&&sum2==n+m)cout<<"Yes"<<endl;
    25     else cout<<"No"<<endl;
    26     return 0;
    27 }

    C题题解:O(n^2)的循环判断当前t和S[i]的大小,小于就需要等,然后判断f[i],t不是f[i]的倍数时也需要等,输出最后的T即可。

    AC代码:

     1 #include<iostream>
     2 #include<algorithm>
     3 #include<cstdio>
     4 using namespace std;
     5 const int maxn = 507;
     6 int c[maxn],s[maxn],f[maxn];
     7 int n;
     8 int main()
     9 {
    10     scanf("%d",&n);
    11     for(int i=1;i<=n-1;i++)
    12     {
    13         scanf("%d%d%d",&c[i],&s[i],&f[i]);
    14     }
    15     int t=0;
    16     for(int i=1;i<=n;i++)
    17     {
    18         t=0;
    19         for(int j=i;j<=n-1;j++)
    20         {
    21             if(t<s[j])t=s[j];
    22             else if(t%f[j]==0);
    23             else t=t-t%f[j]+f[j];
    24             t+=c[j];
    25         }
    26         cout<<t<<endl;
    27     }
    28     return 0;
    29 }

    D题题解:奇数质数筛统计当前符合条件的个数即可,比赛时用了特判一直wa后五组数据,标程是直接选择了前开后闭区间输出个数。

    AC代码:

     1 #include<iostream>
     2 #include<cstring>
     3 #include<map>
     4 using namespace std;
     5 const int maxn = 100007;
     6 int a[maxn+7];
     7 int prime[maxn+7];
     8 int p,n;
     9 void prime1()
    10 {
    11     memset(a,0,sizeof(a));
    12     a[0]=a[1]=1;
    13     for(int i=2;i<=maxn;i++)
    14     {
    15         if(a[i]==0)
    16         {
    17             for(int j=2*i;j<=maxn;j+=i)a[j]=1;
    18         }
    19     }
    20 }
    21 int main()
    22 {
    23     cin>>n;
    24     prime1();
    25     p=1;
    26     prime[1]=prime[0]=1;
    27     for(int i=2;i<=100000;i++)
    28     {
    29         int k=(i+1)/2;
    30         if(i&1)
    31         {
    32             if(a[i]==0&&a[k]==0)
    33             {
    34                 prime[i]=p+1;
    35                 p++;
    36             }
    37             else prime[i]=p;
    38         }
    39         else prime[i]=p;
    40     }N
    41     while(n--)
    42     {
    43         int c,b;
    44         cin>>b>>c;
    45         cout<<prime[c]-prime[b-1]<<endl;
    46     }
    47     return 0;
    48 }
  • 相关阅读:
    MM and Desinger
    db subsequent and synchronization(transfer)
    Thread concepts
    Threads concepts
    lucene article
    primary key
    lucene
    page procedure
    connection pool
    page procedures
  • 原文地址:https://www.cnblogs.com/sortmin/p/8153523.html
Copyright © 2011-2022 走看看