We share codes. We love code. We respect programming

LightBlog

Breaking

LightBlog

Sunday 7 May 2017

Codeforces T-Shirt Hunt Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int p,y,s,cnt=0;
    cin >> p >> s >> y;

    while(1)
    {
        int i = (s/50)%475;
        for(int j=0;j<25;j++)
        {
            i = (i * 96 + 42)%475;
            if((i+26)==p)
            {
                cout << cnt << endl;
                return 0;
            }
        }
        int t = s,c=0;
        t -= 50;
        while(t>=y)
        {
            int j = (t/50)%475;
            for(int k=0;k<25;k++)
            {
                j = (j * 96 + 42)%475;
                if((j+26)==p)
                {
                    cout << cnt << endl;
                    return 0;
                }
            }
            c++;
            t -= 50;
        }
        s += 100;
        cnt++;
    }
    return 0;
}

No comments:

Post a Comment

Adbox