Educational Codeforces Round 7

Educational Codeforces Round 7

2月11号
***
A - Infinite Sequence

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f
 LL n;
 LL l,r;
int main()
{
    while(scanf("%I64d",&n)!=EOF)
    {
        l=1LL;r=1LL;
        for(LL i=2LL;  ; i++)
        {
            r=l+i;
            if(r>=n)
            {
                break;
            }
            l=r;
        }
        printf("%I64d\n",n-l);
    }
    return 0;
}

B - The Time

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f
int n,m;
int t;
int main()
{
    while(scanf("%d:%d",&n,&m)!=EOF)
    {
        scanf("%d",&t);
        t%=1440;
        int hh=t/60;
        int mm=t%60;
        if((23-n)*60+(60-m)>=t)
        {
            if(m+mm<60)
            printf("%02d:%02d\n",n+hh,m+mm);
            else
            printf("%02d:%02d\n",n+hh+1,m+mm-60);
        }
        else
        {
            if(m+mm<60)
            printf("%02d:%02d\n",hh-(23-n),m+mm);
            else
            printf("%02d:%02d\n",hh-(23-n),m+mm-60);
        }
    }
    return 0;

C - Not Equal on a Segment

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f
int a[2*100000+100];
int p[2*100000+100];
int n,m;
int li,ri,xi;
int main()
{
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
            if(a[i]==a[i-1]) p[i]=p[i-1];
            else p[i]=i-1;
        }
        while(m--)
        {
            scanf("%d%d%d",&li,&ri,&xi);
            if(a[ri]==xi)
                if(p[ri]>=li) printf("%d\n",p[ri]);
                else printf("-1\n");
            else
                printf("%d\n",ri);
        }
    }
    return 0;
}

你可能感兴趣的:(Educational Codeforces Round 7)