Thursday, April 30, 2015

485A - Factory(Codeforces)

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std ;
#define pf printf
#define sf scanf
#define loop(i, n) for(i=0; i<n; i++)
#define MAX 500

int main()
{
    int a, m, i, rem;
    while(sf("%d%d", &a, &m)==2)
    {
        loop(i, MAX)
        {
            rem = (a%m);
             if(rem==0)
                break;
            a+=rem;
        }
         if(rem==0)
            pf("Yes\n");
         else
            pf("No\n");
    }
    return 0;
}

1 comment:

  1. How do you know when to stop? i.e. You set MAX with 500, why not 600 or 300? Thanks

    ReplyDelete

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...